Unable to add new contact - Android -


I try to add new contacts to my android I am the application. However - when I do this and check my contact list then there is no new contact? I have ensured that the display name is unique and has seen some thread but there is no luck yet. Any suggestions? I call the contact class with any other activity.

  public class contacts {public contact (string display name, string email address, reference reference) {super (); ArrayList & LT; ContentProviderOperation & gt; Ops = new arreelist & lt; Content provider operation & gt; (); Int rawContactInsertIndex = ops.size (); Ops.add (ContentProviderOperation.newInsert (RawContacts.CONTENT_URI) .withValue (RawContacts.ACCOUNT_TYPE, blank) .withValue (RawContacts.ACCOUNT_NAME, blank) .build ()); Ops.add (ContentProviderOperation .newInsert (contactContract.Data.CONTENT_URI) .withValueBackReference (ContactsContract.Data.RAW_CONTACT_ID, 0) .withValue (ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE) .withValue (ContactsContract.CommonDataKinds.Email .DATA, Email Address). With more (ContactContact.com.comDirect Email, TEPEP, ContactContact.comCommentIndSindEmailTYPE_WORK) .Build ()); Ops.add (ContentProviderOperation .newInsert (contactContract.Data.CONTENT_URI) .withValueBackReference (Data .RAW_CONTACT_ID, rawContactInsertIndex) .withValue (Data.MIMETYPE, Structured Names. CONTENT_ITEM_TYPE) .withValue (StructuredName .DISPLAY_NAME, displayName) .build ()); Try {ContentProviderResult [] res = context.getApplicationContext () .getContentResolver () .applyBatch (ContactsContract.AUTHORITY, ops); } Grip (RemoteException E) {// Todo Auto-Generated Catch Block e.printStackTrace (); } Grip (Operation Application Exception E) {// TODO Automatic Holding Block e.printStackTrace (); }}}  


Comments