I\'m working on Android 2.0 and am trying to receive a list of all contacts.
Since android.provider.Contacts.People is deprecated, I have to use android
I'm using Samsung Galaxy Note 4, and I donno why none of the above worked for me. I mixed up some and made this woking..
Cursor people = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
people.moveToFirst();
while(people.moveToNext()) {
int nameFieldColumnIndex = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
String contact = people.getString(nameFieldColumnIndex);
int numberFieldColumnIndex = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA);
String number = people.getString(numberFieldColumnIndex);
dbWriter.execSQL("Insert Into ContactsList (ContactName, ContactNumber) Values (" +
"'" + contact.replace("'", "''") + "', '" + number.replace("'", "''") + "')");
}
people.close();