I can't get a working Cursor containing all contact's phone numbers:
I obtain lookupUri using this method:
public static Uri getLookupUri (ContentResolver mContentResolver, String number) {
Uri uri=null;
Cursor contactLookupCursor =
mContentResolver.query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(number)),
new String[] {PhoneLookup._ID, PhoneLookup.LOOKUP_KEY},
null,
null,
null);
if (contactLookupCursor.moveToNext()) {
uri=Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_LOOKUP_URI, contactLookupCursor.getString(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup.LOOKUP_KEY)));
}
contactLookupCursor.close();
return uri;
}
Then I would like to get a Cursor (phones) containing all contact's phone numbers:
String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER};
Cursor phones = localContentResolver.query(lookupUri, projection, null, null, null);
but I only get IllegalArgumentException: Invalid column data1