i get an error "the bind value at index 2 is null" at the line " this.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); This crash occurs only when i try to update many contacts together, and works fine for small numbers of contacts. I have the contacts displayed in a listview and on selection of the contacts using a checkbox and onClick of a button the below method is called. Even though the app crashes, the updation does occur.
public void updateContact(String contactId, String type) {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
String selectPhone = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "='" +
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "'" + " AND " + ContactsContract.CommonDataKinds.Phone.TYPE + "=?";
String[] phoneArgs = new String[]{contactId, type};
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
.withSelection(selectPhone, phoneArgs).build());
try {
this.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
e.printStackTrace();
} catch (OperationApplicationException e) {
e.printStackTrace();
}