Hi! I am updating contact using below code. I am unable to get contact detail by phone number. cursor count is always returning 0, please check it.I think m missing some thing. Need urgent help
cursor = getContentResolver().query(Contacts.Phones.CONTENT_URI, null, Contacts.Phones.NUMBER+" = ?", new String[]{phoneNumber}, null);
Log.d("UpdateContact", phoneNumber);
Log.d("UpdateContact", String.valueOf(this.cur.getCount()));
if(this.cur.moveToFirst())
{
String id = cur.getString(cur.getColumnIndex(People._ID));
Uri baseUri = Uri.withAppendedPath(People.CONTENT_URI, id);
ContentValues values = new ContentValues();
values.put(Contacts.Phones.NAME, "OO "+name);
this.cr.update(baseUri, values, null, null);
//update email
Cursor cursor =
this.cr.query(Contacts.ContactMethods.CONTENT_URI,
new String[] { Contacts.ContactMethods._ID },
Contacts.ContactMethods.PERSON_ID + " = " + id,
null, null);
Uri emailUri = Uri.withAppendedPath(baseUri, People.ContactMethods.CONTENT_DIRECTORY);
values.clear();
values.put(People.ContactMethods.KIND, Contacts.KIND_EMAIL);
values.put(Contacts.ContactMethods.TYPE, People.ContactMethods.TYPE_OTHER);
values.put(People.ContactMethods.DATA, email);
if(cursor.moveToFirst())
{
String personId = cursor.getString(0);
this.cr.update(Uri.withAppendedPath(emailUri, personId), values, null, null);
}
else
{
this.cr.insert(emailUri, values);
}
return true;