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

  • Home
  • SEARCH
  • 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 7505643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:58:55+00:00 2026-05-29T21:58:55+00:00

I succeeded in inserting contacts into the address book and I need to save

  • 0

I succeeded in inserting contacts into the address book and I need to save a reference of the contact in my app. I figured that the best way to save the reference is to get the RawContacts ID itself.

Is there a way for me to directly get the ID back from the address book right after the insertion of the the new contact? Or do I have to get every records out and compare them with my data to get the RawContacts ID?

I do my insert using this code:

ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
int rawContactInsertIndex = ops.size();
ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
    .withValue(RawContacts.ACCOUNT_TYPE, null)
    .withValue(RawContacts.ACCOUNT_NAME, null)
    .withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED)
    .build());

I appreciate any inputs, be it a workaround or from the API. Thanks!

  • 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-05-29T21:58:57+00:00Added an answer on May 29, 2026 at 9:58 pm

    you can use the information returned from getContentResolver() (which you anyways have to call in order to add ops to the DB.
    getContentResolver() needs to have a try,catch environment.

    ...
    ContentProviderResult[] res = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
    ...
    Uri myContactUri = res[0].uri;
    int lastSlash = myContactUri.toString().lastIndexOf("/");
    int length = myContactUri.toString().length();
    int contactID = Integer.parseInt((String) myContactUri.toString().subSequence(lastSlash+1, length));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw that vizzed.com succeeded at embedding zSnes into a web browser. I want
According to this question I succeeded to create upload image, but now I need
I need to know if all the client-side validator checks have succeeded, or if
Has anyone succeeded to compile a Win32 GUI app with the command line dcc32.exe
I have succeeded in generating a sqlite3 database in my android app from an
In a single operation, I am inserting multiple rows into a table. It is
I finally succeeded in building my first iPhone app but now I am pulling
So far, I have succeeded to authenticate my app. Now I want to know
I need to insert some data in bulk into an azure storage table. As
I just created a TablView and i succeeded to put data into it. The

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.