Hi
I am trying to fetch contacts first and last name.But getting fail.
I am using the following code.
String id;
String[] projection = new String[]
{ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME,ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME};
String where = ContactsContract.CommonDataKinds.StructuredName._ID+ " = ?
AND "+ ContactsContract.CommonDataKinds.StructuredName.MIMETYPE+ " = ?";
id = Get_Id(contact_id);
String[] whereParameters = new String[]
{id,ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
Cursor cursor =
cr.query(ContactsContract.Data.CONTENT_URI,projection, where,
whereParameters, null);
if(cursor.moveToFirst())
{
String contact_given_name =
cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
String contact_family_name =
cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
}
cursor.close();
but its giving null. where is the problem?
Take care.
Regards
Goutom Roy
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en