Search code examples
androidcontactscontractandroid-contactscalllog

How to get the id of the contact on Android contact list?


Hey, I want to get the id of the contact which is in the list of contacts on Android. I mean, when I add a contact to the phone, I think it has an Id, what is the class that provides this parameter? I mean the exactly Id.

I've search if some constants on CallLog.Calls can provide it, but I didn't found. Maybe it's Contacts.Contract, I don't know. Does anyone knows?

Thanks!


Solution

  • Depends on the lowest API level you want to support. If it is API level 5 (2.0 Eclair) and above then ContactsContract.Contacts should be the class you are looking for. If you are developing for API levels below then the Contacts class is your friend.