Friday, 16 August 2013

Force Close in use "ContactsContract.CommonDataKinds.StructuredName"

Force Close in use "ContactsContract.CommonDataKinds.StructuredName"

I want to get first name and last name separately from contacts.
But when I use the following procedure, the program has a run time error.
(Unfortunately, XXX has stopped.)
Where is the problem?
thanks.
private void PrintContacts(Cursor c){
if(c.moveToFirst()){
do{
String contactID =
c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
**String contactGivenName =
c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));**
Toast.makeText(this, contactGivenName,
Toast.LENGTH_SHORT).show();
}while(c.moveToNext());
}
}

No comments:

Post a Comment