How to get first name and last name from contact list?
Take a look at the Contact Manager sample project for code to do this.
try this:
String whereName = ContactsContract.Data.MIMETYPE + " = ?";
String[] whereNameParams = new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
Cursor nameCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, null, whereName, whereNameParams, ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME);
while (nameCur.moveToNext()) {
String given = nameCur.getString(nameCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
String[] str = given.split(' ');
String fname=str[0]; // FIRST NAME
String lname=str[str.length-1]; // LAST NAME
}
nameCur.close();
for more details see this post How to get the firstname and lastname from android contacts?