my code is as following
String projection[] = new String[]{ ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME };
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, //The URI, using the content:// scheme, for the content to retrieve.
projection, // projection
null, // selection
null, // selectionArgs
ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
I want to add contact id, name and number (MAIN or any one of type) to intent, but problem is that I am unable to access Name. And another problem is that for each contact id returns “-1”. why?
Is there any solution?
Instead off supplying the value of
projectionvariable asnullin thequerymethod you should try it like this:It is clearly written in Android Developer Documentation that:
See here in the documentation:
http://developer.android.com/reference/android/widget/CursorAdapter.html