Code example for ContentResolver

Methods: applyBatch

0
        // update that photo 
        operations.add(ContentProviderOperation.newUpdate(rawContactDataUri).withSelection(Photo.MIMETYPE + "=?", new String[] {
                    Photo.CONTENT_ITEM_TYPE}).withValues(values).build());
 
        try { 
            mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations);
        } catch (RemoteException e) {
            throw new IllegalStateException("Problem querying raw_contacts/data", e);
        } catch (OperationApplicationException e) {
            if (allowInsert) {
                // they deleted the photo between insert and update, so insert one 
                insertPhoto(values, rawContactDataUri, false);
            } else { 
                throw new IllegalStateException("Problem inserting photo raw_contacts/data", e);
            } 
        } 
    } 
}