1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
String where = ContactsContract.Contacts.DISPLAY_NAME + " = ?";
String[] whereArgs = new String[] {nom};
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
Uri contactUri = intent.getData();
Cursor cursor = getContentResolver().query(contactUri, null, where, whereArgs, null);
if (cursor.moveToFirst())
{
String idCont = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(Data.LOOKUP_KEY +" = ?", new String[]{String.valueOf(idCont)})
.withValue(Email.ADDRESS, email)
.build());
} |