I used to use a content resolver to get a list of contacts and their data while it still works. I wanted to try the Loader method, which requests the content provider in the background. I looked at the documentation and sample code here:
http://developer.android.com/training/contacts-provider/retrieve-details.html
While I was able to display the contact list without any problems, I was stuck in getting the phone number of a specific contact when I click on it and show it on the detailed screen. The demo above shows the user address on the details screen, I even tried to change it. I changed the content URI from contacts in ContactsContract.CommonDataKinds.Phone, but I keep getting
java.lang.IllegalArgumentException: Invalid column data1
There is not a single detailed tutorial on the Internet showing how to do this. Can someone here be kind enough to shed light? While reading various other questions related to Stackoverflow, I am sure that it has something to do with 2 different URI CONTENTs, but again I am wrong. Any help or pointers would be really appreciated. Thanks
A few of the SO questions I have already looked at are:
Get phone number from contact bootloader in android: projection crash
Logcat says "invalid column1 data"
How to get a phone number for contacts in Android
Getting a phone number from a search URI
None of them solves my problem. Here is the relevant code where it fails:
final static String[] PROJECTION = { Contacts._ID, Utils.hasHoneycomb() ? ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY : ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
The code works very well, but the moment I delete the comment to get the phone number, it fails
android contacts
Adnan Mulla Feb 16 '14 at 13:30 2014-02-16 13:30
source share