I am trying to add contacts from my application to the phonebook and
then update it later through my application itself. As mentioned, to
uniquely identify the contact I am using the lookup key as follows:
Uri lookupUri =
Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,
lookupKey);
Uri res =
ContactsContract.Contacts.lookupContact(context.getContentResolver(),
lookupUri);
Cursor t_cursor = context.getContentResolver().query(res, null, null,
null, null);
String t_id =
t_cursor.getString(t_cursor.getColumnIndex(ContactsContract.Contacts.Data._ID));
String t_contactId =
t_cursor.getString(t_cursor.getColumnIndex(ContactsContract.Contacts._ID));
using the above I am trying to update the contact as follows:
String Where = ContactsContract.Contacts.Data._ID + " =
'"+t_id
+"'";
ContentValues values = new ContentValues();
values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
modified_name+"P");
values.put(Email.TYPE, Email.TYPE_WORK);
values.put(Email.DATA, email);
values.put(Organization.TITLE, title);
values.put(Organization.COMPANY, "XYZ");
context.getContentResolver().update(Data.CONTENT_URI, values,
Where, null);
But nothing is getting updated using this. I tried using the t_id as
well as t_contactId for the where clause but it made no difference.
Could anyone please suggest where am I going wrong ?
--
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