I get an error when I want to access a specific contact.
java.lang.IllegalArgumentException: invalid contact_id column
Here is a sample code:
String number = "0877777777";
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
String[] projection = new String[]{ ContactsContract.PhoneLookup.CONTACT_ID };
Cursor cur = getActivity().getContentResolver().query(uri, projection, null, null, null);
if (cur != null && cur.moveToNext()) {
Long id = cur.getLong(0);
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(id));
intent.setData(contactUri);
startActivity(intent);
cur.close();
}
Projection error, but I'm not sure how to fix it. The number is stored on the tested phone. Any advice on solving the problem would be much appreciated.
source
share