Android – Reading contacts from phone book in Android

androidsdk

I 'm trying to read and display contacts from phone book in android. My Device is synced up with gmail and funambol which togehter have more than 600 records. Now by default my application reads gmail contacts. On selecting any contact from the displayed list, it throws an exception as the list is displaying a gmail contact which just has email and no phone no.

I need phone no to use in my application.

thanks

Best Answer

Take a look at this answer here. It provides all the detail you need to get the contacts right.

The reason for the crash might be because you are trying to read the phone number when there is none, causing a NullPointerException. Maybe check if it's null before you try and use it, and if it is null then ask the user to pick again.

If this isn't right, feel free to provide more detail like code and logcat logs.