Key content provider docs

content provider basics

Main guide to content providers

Here is how batch operations are explained

Each content provider update operation is encapsulated in an object called "ContentProviderOperation" along with the URI and all

You make a list of those

You tell the Content Resolver to apply the batch one time

Transactions are applied at the end of all operations

If an operation says that transaction can be applied at that point, then it will be dealt as the end of a unit of operation. this allows you to sub-batch your long updates of many rows

You can also say in an operation one of the columns to be updated needs to use the key returned by an indexed previous operation

thats it


Batch them
Yield when needed
use an id from a previous operation

//A list of operations
ArrayList<ContentProviderOperation> ops =  new ArrayList<ContentProviderOperation>();

//Get a builder
ContentProviderOperation.Builder op =
            ContentProviderOperation.newInsert(a content URI);
op.withValue(key, value);
//...more of these
ContentProviderOperation op1 = op.build();
ops.add(op1);

//Do more of these
op = ContentProviderOperation.newInsert(a content URI);
op.withValue(key, value);
//...more of these
//Take the key coming out of op1 and add it as the value 
op.withValueBackOperation(mykey, 0);
op.withYieldAllowed(true); //it is ok to commit

ContentProviderOperation op2 = op.build();
ops.add(op2);

contentResolver.apply(ops);

ContentProviderOperation
ContentProviderOperation.Build
   withValue
   withValueBackReference
   withYieldAllowed
   build
contentResolver.apply()

Read this documentation on optimistic locking

Syncadapters are documented here

Reusing the UI of the contacts application is documented here