How to get contact details in Android

Given the contact identifier, I can get various contact details (e.g. name, phone, email address, etc.) by creating different requests for each of these fields.

But is there a method to get all the details associated with this contact identifier by creating a single request?

+7
android contacts
Feb 05 '10 at 5:30
source share
1 answer

I had to change the Content Providers tutorial a bit, as this refers to obsolete classes, this may help.

import android.provider.ContactsContract.Contacts; import android.database.Cursor; // Form an array specifying which columns to return, you can add more. String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone ContactsContract.CommonDataKinds.Email }; Uri contacts = ContactsContract.Contacts.CONTENT_LOOKUP_URI; // id of the Contact to return. long id = 3; // Make the query. Cursor managedCursor = managedQuery(contacts, projection, // Which columns to return null, // Which rows to return (all rows) // Selection arguments (with a given ID) ContactsContract.Contacts._ID = "id", // Put the results in ascending order by name ContactsContract.Contacts.DISPLAY_NAME + " ASC"); 
+12
Feb 05 '10 at 5:51
source share



All Articles