Android contacts: updating, deleting, inserting -


I have a problem with the original operation on the contact pane, it seems that official examples do not work for me :

  ops.add (ContentProviderOperation.newInsert (Data.CONTENT_URI) .withValue (Data.RAW_CONTACT_ID, ID) .withValue (Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) .withValue (phone.NUMBER, "1-800-GOOG-411") .withValue (Phone TYPE, phone.TYPE_CUSTOM) .withValue (Phone.LABEL, "Free Directory Support") .build ());   

It should add a contact with the given ID, but I did not get a new contact after running this code in the emulator.

I actually link to any guide answers or tutorials.

You must have the following permissions:

  < Usage-permission Android: name = "android.permission.WRITE_CONTACTS" & gt; & Lt; / Usage-permission & gt; & Lt; Usage-permission Android: name = "android.permission.READ_CONTACTS" & gt; & Lt; / Usage-permission & gt;   

You must have the code (after your code):

  try {getContentResolver (). ApplyBatch (ContactsContract.AUTHORITY, ops); } Hold (exception e) {e.printStackTrace (); }   

This will try to insert / update

Comments