Java Code Examples for android.content.ContentProviderOperation.apply()

The following are Jave code examples for showing how to use apply() of the android.content.ContentProviderOperation class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Phoenix-for-VK   File:   Source Code and License Vote up 5 votes
public ContentProviderResult[] applyBatch(@NonNull ArrayList<ContentProviderOperation> operations) {
    if(Utils.safeIsEmpty(operations)) {
        return new ContentProviderResult[0];


    int aid = extractAidFromUri(operations.get(0).getUri());

    ContentProviderResult[] result = new ContentProviderResult[operations.size()];
    int i = 0;
    // Opens the database object in "write" mode.
    SQLiteDatabase db = getDbHelper(aid).getWritableDatabase();
    // Begin a transaction
    try {
        for (ContentProviderOperation operation : operations) {
            // Chain the result for back references
            result[i++] = operation.apply(this, result, i);

    } catch (OperationApplicationException e) {
        Logger.d("DATABASE", "batch failed: " + e.getLocalizedMessage());
    } finally {

    return result;