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 7683595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:49:47+00:00 2026-05-31T18:49:47+00:00

I am working on android apps. I want to add a contact in android

  • 0

I am working on android apps. I want to add a contact in android phone group. The code I am using is below:

    ContentValues values = new ContentValues();
                    values.put(ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID,personId);

    values.put(
        ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,GROUP_ID);

    values.put(
        ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE,ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE);

    Log.d("values :", ""+ values);

    this.getContentResolver().insert(   
                 ContactsContract.Data.CONTENT_URI, values);

Unfortunately, this is not working. Does anyone see anything obviously wrong with the above code?

  • 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-31T18:49:49+00:00Added an answer on May 31, 2026 at 6:49 pm

    Bellow code is worked perfect in my side. So, Please try it or you can download sample example from chetanbhalala

    try
    {
    
       // Add selected contact to selected group
       ContentValues values = new ContentValues();
           values.put(ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID,Integer.parseInt(245)); // 245 is a contact id, replace with selected contact id
    
           values.put(ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,3);// 3 is a group id, replace with selected group id
    
           values.put(ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE,ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE);
    
           ContextWrapper context = this;
           context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
           // End add contact to group code
    }
    catch (Exception e) 
    {
       // TODO: handle exception
       Log.d("add group error :", ""+ e.getMessage().toString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using Monodroid to develop an android app. I'm rather new to phone
I'm working on a picture select/crop program and using this code below: http://www.androidworks.com/crop_large_photos_with_android/comment-page-1#comment-969 As
I'm quite new to developing Android apps. Basically I'm making a webview template to
I'm learning Android development using Pro Android Web Apps (Apress, Auths: Damon Oehlman &
I want to know mobile number from android apps.I searched in here.some one give
i have done android dev. in the past.I want to start working on developing
We have started working on samsung bada platform for our existing android apps and
I developed an App for Android and iOS using Phonegap. Both Apps are already
I'm working on an Android application that will send MMS internally without using the
I am working eclipse to develop android apps in ubuntu OS.I am getting sqlite

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.