apply Batch via ContentProviderOperation - Android android.content

Android examples for android.content:ContentProviderOperation

Description

apply Batch via ContentProviderOperation

Demo Code


//package com.book2s;
import java.util.ArrayList;

import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;
import android.content.Context;
import android.content.OperationApplicationException;
import android.os.RemoteException;

public class Main {
    public static ContentProviderResult[] applyBatch(Context context,
            String contentAuthority,
            ArrayList<ContentProviderOperation> batch) {
        final ContentResolver resolver = context.getContentResolver();
        try {// w  ww  . j a va2  s.c  om
            // Apply all queued up batch operations for local data.
            return resolver.applyBatch(contentAuthority, batch);
        } catch (RemoteException e) {
            throw new RuntimeException("Problem applying batch operation",
                    e);
        } catch (OperationApplicationException e) {
            throw new RuntimeException("Problem applying batch operation",
                    e);
        }
    }
}

Related Tutorials