EDIT ::: The code works. It was a problem with Eclipse, and the code displays the output in logcat as intended.
Android 2.3.3
I am pretty new to using conten
try this
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while (cursor.moveToNext()) {
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
System.out.println(contactId + " " + name);
}
cursor.close();
it returns the contact's name and the id (the id is probably the row number of the contacts table)