Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Contacts RAW_CONTACT_ID vs CONTACT_ID

I am using a contact picker as follows:

Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
                                        Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT)

What I want to know is whether the last path segment of the returned URI is the CONTACT_ID or the RAW_CONTACT_ID.

In case it is the CONTACT_ID, how do I retrieve all RAW_CONTACT_IDs from this contact?

like image 617
Mak Avatar asked Nov 29 '10 09:11

Mak


1 Answers

You will get CONTACT_ID as the return data.

In case if you need to get the list of all the RAW_CONTACT_ID of the contact here is what you can include in

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {       
    super.onActivityResult(requestCode, resultCode, data);

     if ((requestCode == 1) && (resultCode == RESULT_OK)){

         Uri contactData = data.getData(); 
         // This gives the value of Contact URI                  
         Cursor c =  managedQuery(RawContacts.CONTENT_URI,  new String[] {RawContacts._ID}, RawContacts.CONTACT_ID + " = " +  contactData.getLastPathSegment(), null, null); 
         // This query would give you list of Raw_COntact_ID for the added contact
     }
}
like image 125
Manish Khot Avatar answered Nov 04 '22 13:11

Manish Khot