1

I am using the new Android 2.2 API to add a contact. I am using the following code to perform the insert.

ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
    .withValue(Data.RAW_CONTACT_ID, id)
    .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
    .withValue(Data.DISPLAY_NAME, first_name)
    .withValue(Phone.NUMBER, pnumber)
    .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
    .build());
try {
    getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {}
catch (OperationApplicationException e) {}

The code executes fine without any exception. However, the new contact is not visible in the Android Contacts. I tried searching on the net but couldn't find any answer. What I might be doing wrong ?

Cristian
  • 198,401
  • 62
  • 356
  • 264
Mako
  • 1,465
  • 2
  • 18
  • 34
  • can you see the fields for the user to fill in like the number and email? cause i can't – Mikey Sep 14 '10 at 08:49
  • Well I'm not surprised that it executes without exception. You have empty catch blocks. – Tom Apr 02 '11 at 22:27

0 Answers0