in the Contacts API, there is a difference between querying a contact in the RawContact table, and in the Contacts table (as shown below : Data.RAW_CONTACT_IDor Data.CONTACT_ID) :
in which case can i retrieve the contact id, and in which other case will i retrieve a raw_contact id?
for example, if we want to pick a contact, will it return the raw_contact_id or the contact_id of my query?
Here’s the code from the doc :
Query
Finding all Data of a given type for a given contact
Cursor c = getContentResolver().query(Data.CONTENT_URI,
new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
Data.CONTACT_ID + "=?" + " AND "
+ Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
new String[] {String.valueOf(contactId)}, null);
Finding all Data of a given type for a given raw contact
Cursor c = getContentResolver().query(Data.CONTENT_URI,
new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
Data.RAW_CONTACT_ID + "=?" + " AND "
+ Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
new String[] {String.valueOf(rawContactId)}, null);
Thanks
You can use Data._ID or Data.RAW_CONTACT_ID, both of them refer to the same contact.
ContactsContract.RawContactsColumns.CONTACT_ID also is same as Data._ID