Modifier le nom d'un contact avec newUpdate
Bonjour,
je souhaite modifier seulement le nom et prenom du contact dans ContactsContract.
Le problème, il me modifie les numeros de telephone ..., je ne comprends pas pourquoi!!
Code:
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>();
//recherche vers id souhaité
String orgWhere = Data.CONTACT_ID + " = ? ";
String[] orgWhereParams = new String[]{ CONTACT_ID};
System.out.println("prenom modifier idcontact:"+TokenContact);
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(orgWhere, orgWhereParams)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,nom_modif.toString() ) // Le nom qui devrait être utilisé pour afficher le contact.
.withValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, nom_modif.toString())//Le nom de famille
.withValue(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME, prenom_modif.toString())// prenom of the person
.build());
try {
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperationApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} |
merci pour votre aide
cedric