Categories
Android code Java Mobile phones programming tips

Reading contacts in Android 2.0+

On one of my Android apps, I added a trivial option to select a contact from the phone’s contact list. This was working fine until SDK version 5, which changed the way the contacts are represented in the phone’s SQLite database. It is using the “newer” class called ContactsContract instead of the deprecated People class

I have spent quite time in order to figure out which was the best way that will fit my needs. If you are in the same position, feel free to use the code below

My example below is will display a two row list of all the contacts, with alphabetical indexing. It is a mixture of code snippets I have found on the net, while may not be optimized; it will definitely give you the hang of things.