Pick first and last name from contact list

Go To StackoverFlow.com

1

How to get first name and last name from contact list?

2012-04-04 05:36
by atrivedi
Keep trusting Google more! - Paresh Mayani 2012-04-04 05:45
Why dont you just search ones "Android How to get contact info programmatically? - MKJParekh 2012-04-04 06:07


1

Take a look at the Contact Manager sample project for code to do this.

2012-04-04 05:44
by Ted Hopp


0

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?

2012-04-04 05:46
by ρяσѕρєя K
Ads