Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:05:18+00:00 2026-06-11T19:05:18+00:00

ArrayList<ContentProviderOperation> ops =new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValue(Data.RAW_CONTACT_ID, 3) .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) .withValue(Phone.NUMBER, 999999999) .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) .withValue(Phone.DISPLAY_NAME,

  • 0
ArrayList<ContentProviderOperation> ops =new ArrayList<ContentProviderOperation>();
         ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                  .withValue(Data.RAW_CONTACT_ID, 3)
                  .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
                  .withValue(Phone.NUMBER, "999999999")
                  .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
                  .withValue(Phone.DISPLAY_NAME, "hhhhhhh")
                  .withValue(ContactsContract.CommonDataKinds.Email.DATA, "abcd@gmail.com")
                  .build());
         ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                  .withValue(Data.RAW_CONTACT_ID, 4)
                  .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
                  .withValue(Phone.NUMBER, "999999999")
                  .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
                  .withValue(Phone.DISPLAY_NAME, "hhhlllllllllll")
                  .withValue(ContactsContract.CommonDataKinds.Email.DATA, "efgh@gmail.com")
                  .build());

         try {
             cr.applyBatch(ContactsContract.AUTHORITY, ops);
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (OperationApplicationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

I have added <uses-permission android:name="android.permission.WRITE_CONTACTS"/> permission.

I am getting the following errors:

09-25 09:30:41.365: W/System.err(1057): android.content.OperationApplicationException: insert failed
09-25 09:30:41.375: W/System.err(1057):     at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:161)
09-25 09:30:41.375: W/System.err(1057):     at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:461)
09-25 09:30:41.375: W/System.err(1057):     at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:225)
09-25 09:30:41.375: W/System.err(1057):     at android.content.ContentResolver.applyBatch(ContentResolver.java:901)
09-25 09:30:41.375: W/System.err(1057):     at com.example.projdemo.MainActivity.onCreate(MainActivity.java:136)
09-25 09:30:41.375: W/System.err(1057):     at android.app.Activity.performCreate(Activity.java:5008)
09-25 09:30:41.385: W/System.err(1057):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-25 09:30:41.385: W/System.err(1057):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-25 09:30:41.385: W/System.err(1057):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-25 09:30:41.385: W/System.err(1057):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-25 09:30:41.385: W/System.err(1057):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-25 09:30:41.395: W/System.err(1057):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 09:30:41.395: W/System.err(1057):     at android.os.Looper.loop(Looper.java:137)
09-25 09:30:41.395: W/System.err(1057):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-25 09:30:41.395: W/System.err(1057):     at java.lang.reflect.Method.invokeNative(Native Method)
09-25 09:30:41.395: W/System.err(1057):     at java.lang.reflect.Method.invoke(Method.java:511)
09-25 09:30:41.395: W/System.err(1057):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-25 09:30:41.395: W/System.err(1057):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-25 09:30:41.405: W/System.err(1057):     at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:05:20+00:00Added an answer on June 11, 2026 at 7:05 pm

    Try as follows :

    private void addContact() {
        ArrayList<ContentProviderOperation> op_list = new ArrayList<ContentProviderOperation>(); 
        op_list.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) 
                .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null) 
                .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null) 
                //.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DEFAULT) 
                .build()); 
    
        // first and last names 
        op_list.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 
                .withValueBackReference(Data.RAW_CONTACT_ID, 0) 
                .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) 
                .withValue(StructuredName.GIVEN_NAME, "Second Name") 
                .withValue(StructuredName.FAMILY_NAME, "First Name") 
                .build()); 
    
        op_list.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 
                .withValueBackReference(Data.RAW_CONTACT_ID, 0) 
                .withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
                .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, "09876543210")
                .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, Phone.TYPE_HOME)
                .build());
        op_list.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) 
                .withValueBackReference(Data.RAW_CONTACT_ID, 0)
    
                .withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)
                .withValue(ContactsContract.CommonDataKinds.Email.DATA, "abc@xyz.com")
                .withValue(ContactsContract.CommonDataKinds.Email.TYPE, Email.TYPE_WORK)
                .build());
    
        try{ 
            ContentProviderResult[] results = getContentResolver().applyBatch(ContactsContract.AUTHORITY, op_list); 
        }catch(Exception e){ 
            e.printStackTrace(); 
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues row1 = new ContentValues(); row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); row1.put(Organization.COMPANY, Android);
This is the code ArrayList<MyObject> list = new ArrayList<MyObject>(); list.add(new MyObject()); Intent intent =
ArrayList<yellowPage> ob1 = new ArrayList<yellowPage>(); yellowPage thing = new yellowPage(100,100); thing.calc(i,y,s3); ob1.add(thing); I stored
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair( product_name, product_name)); nameValuePairs.add(new BasicNameValuePair(brand, brand_product)); nameValuePairs.add(new BasicNameValuePair(reference_price,
ArrayList<String> emplist = new ArrayList<String>(); //Inside the array I add list of employee that
ArrayList<Rectangle> list = new ArrayList<Rectangle>(); for (int i=0; i < 10; i++) { list.add(new
ArrayList<Object> list = new ArrayList<Object>(); list.add(1); list.add(Java); list.add(3.14); System.out.println(list.toString()); I tried: ArrayList<String> list2 =
ArrayList<String> myArr = new ArrayList<String>(); then add some stuff to it myArr.add(Hello); myArr.add(Testing); myArr.add(Testing
Im trying to add a phone number to an already existing contact on a
I am able to insert new android contact's name, his all phone number and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.