开发者

Android Contacts RAW_CONTACT_ID vs CONTACT_ID

开发者 https://www.devze.com 2023-01-27 04:30 出处:网络
I am using a contact picker as follows: Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);

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 CO开发者_Python百科NTACT_ID, how do I retrieve all RAW_CONTACT_IDs from this contact?


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
     }
}


Do you need to use the CONTACT_ID ?

Otherwise, I recommend you use LOOKUP_KEY instead.

See 1 and 2

0

精彩评论

暂无评论...
验证码 换一张
取 消