I need to get the name, email and phone number from each contact of my contacts list.
The problem is I can get name and phone number, but not the email. I'm getting the phone number instead of email.
Here is my code:
Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,null, null);
while (phones.moveToNext()) {
String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
String email = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS));
ContactItem objContact = new ContactItem();
objContact.setName(name);
objContact.setPhoneNo(phoneNumber);
objContact.setEmail(email);
list.add(objContact);
}
phones.close();