0

I have inserted few contacts in through the android emulator.

I wanted to fetch the names, number,emails,etc. for each contact.

I understood that for fetching contact number we need to refer to

ContactsContract.CommonDataKinds.Phone.CONTENT_URI

instead of

ContactsContract.Contacts.CONTENT_URI

My question is how do i link both the query results so that i can aggregate a single contact and its attributes together ? It seems that only ContactsContract.Data.DISPLAY_NAME is common in both the results and the only attribute which can fetched in both the URI's without specifying in the query's projection.

Can anyone guide me ?

Thanks, Adithya.

Adithya
  • 2,923
  • 5
  • 33
  • 47

3 Answers3

2

try these links:

How to call Android contacts list?

How to get contacts from native phonebook in android

How to obtain all details of a contact in Android

How to get the first name and last name from Android contacts?

How to import contacts from phonebook to our application

Android contacts extraction

How to get all android contacts but without those which are on SIM

Community
  • 1
  • 1
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • can you tell me one thing ? If we can fetch all these in one query as it can be done in the third specified link then why do we have different URI's for each of the following : 1)ContactsContract.CommonDataKinds.Phone 2)ContactsContract.CommonDataKinds.Email etc.. ? – Adithya Oct 08 '11 at 10:50
0

Use select from ContactsContract.Data.CONTENT_URI and group results by LOOKUP_KEY. You'll receive a single cursor with phones, emails, etc., grouped by contact.

Ash
  • 1,701
  • 13
  • 18
0

In onactivityresult we r getting cursor to the contact database to access various fields of contact database we have ContactsContract.PhoneLookup through which we can get index various db columns and then acccess them.

Ashwin N Bhanushali
  • 3,872
  • 5
  • 39
  • 59