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 ?