Given:
Uri contactLookupURI = ContactsContract.Contacts.getLookupUri(contactID, lookupKey);
How do I use this to get a contact's details such as phone, email, etc?
I tried:
String[] CDETAIL_PROJECTION = {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME_PRIMARY,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Email.ADDRESS,
};
Cursor detail_cursor = getContext().getContentResolver().query(contactLookupURI, CDETAIL_PROJECTION, null, null, null);
But I get an error saying "Invalid column: data1" which I guess refers to Phone.NUMBER
field. This might be because it's referring to the Contacts table which doesn't have that field?
According to other answers, I can use the _ID
to get the contact details but I want to use the URI only.
Also, can you tell me what
ContactsContract.Contacts.lookupContact()
does? The documentation illustrates that it gives me the Content URI but how's it any different than the Lookup URI?