I recently created a sync adapter for my application. It synchronizes the contacts that I receive through a web request with the contacts in the phone. I have no problem adding a contact, but I canβt get the contact information to properly update the information when the contact information has changed. For example, the "Company name" field on the contact. Here are some examples of requests that I tried that didnβt work or partially worked (i.e. some contacts are updated, but not correctly):
ContentValues values = new ContentValues(); values.put(ContactsContract.CommonDataKinds.Organization.COMPANY, "New Company"); context.getContentResolver().update(Uri.parse("content://com.android.contacts/data/"), values, BaseColumns._ID + "=?", new String[] { String.valueOf(id) } );
I also tried doing this in a package, as suggested in the Android documentation:
builder = ContentProviderOperation .newUpdate(ContactsContract.Data.CONTENT_URI); builder.withSelection(BaseColumns._ID + " =?", new String[]{String.valueOf(id)}); builder.withValue( ContactsContract.CommonDataKinds.Organization.COMPANY, "New Company Name!"); operationList.add(builder.build());
I read the ContactContracts Documentation and originally followed this tutorial . I also checked the AuthenticatorActivity example in the api to no avail. Any help is appreciated.
source share