Hi. Why is this code throwing a NullPointerException when called from
a Sync Adapter?
final ContentResolver resolver = context.getContentResolver();
final BatchOperation batchOperation = new
BatchOperation(context,
resolver);
long rawContactId =
cursorContacts.getInt(cursorContacts.getColumnIndex(ContactsContract.Contacts._ID));
batchOperation.add(ContactOperations.newDeleteCpo(ContentUris.withAppendedId(RawContacts.CONTENT_URI,
rawContactId), true).build());
batchOperation.execute(); //this throws the exception
where cursorContacts is the cursor for the contacts to be deleted and
newDeleteCpo is defined like this:
public static ContentProviderOperation.Builder newDeleteCpo(Uri uri,
boolean yield) {
return
ContentProviderOperation.newDelete(addCallerIsSyncAdapterParameter(uri)).withYieldAllowed(yield);
}
The value returned by
cursorContacts.getInt(cursorContacts.getColumnIndex(ContactsContract.Contacts._ID));
seems correct.
The contact is not shown any-more after executing the command.
The exception is weird: NullPointerException with cause =
NullPointerException with cause = NullPointerException....
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en