Hello,
According to documentation youi can retrieve all contacts using following code.
Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
new String[]{RawContacts._ID},
RawContacts.CONTACT_ID + "=?",
new String[]{String.valueOf(contactId)}, null);
And the best way to read a raw contact along with all the data associated with it is by using the ContactsContract.RawContacts.Entity directory. More info[
^].
For your problem change projection declaration as
final String[] projection = new String[] {RawContacts.CONTACT_ID};
Regards,