0

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();
    }
Abhijith
  • 37
  • 2
  • 8
  • I think this could help you out------ http://stackoverflow.com/questions/8788053/modifying-contact-information http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html – Chaudhary Amar Jun 30 '15 at 09:14
  • sorry, as im new to this, i couldnt resolve the issue from those links. – Abhijith Jun 30 '15 at 09:24
  • these are straight answers which you can add in your project---- http://androiddevelopement.blogspot.in/2011/07/insert-update-delete-view-contacts-in.html http://wptrafficanalyzer.in/blog/adding-contacts-programatically-using-contacts-provider-in-android-example/ http://stackoverflow.com/questions/3351545/how-to-update-contact-number-using-android – Chaudhary Amar Jun 30 '15 at 09:36
  • i have done the same thing as given in the answer from http://stackoverflow.com/questions/3351545/how-to-update-contact-number-using-android – Abhijith Jun 30 '15 at 09:43

0 Answers0