Si vous ne l'avez pas résolu encore voilà comment je le fais. En aucun cas je ne suggère que c'est une solution efficace. C'est juste la solution directe.
Recherchez d'abord tous les ID de contact ayant un ID de groupe spécifique. Puis créer un ContentProviderOperation
pour chaque contact à supprimer et appliquer la dernière liste d'opérations de suppression.
private void deletaAllInGroup(Context context, long groupId)
throws RemoteException, OperationApplicationException{
String where = String.format("%s = ?", GroupMembership.GROUP_ROW_ID);
String[] whereParmas = new String[] {Long.toString(groupId)};
String[] colSelection = new String[] {Data.CONTACT_ID};
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
colSelection,
where,
whereParmas,
null);
ArrayList<ContentProviderOperation> operations =
new ArrayList<ContentProviderOperation>();
// iterate over all contacts having groupId
// and add them to the list to be deleted
while(cursor.moveToNext()){
String where = String.format("%s = ?", RawContacts.CONTACT_ID);
String[] whereParams = new String[]{Long.toString(cursor.getLong(0))};
operations.add(ContentProviderOperation.newDelete(RawContacts.CONTENT_URI)
.withSelection(where, whereParams)
.build());
}
context.getContentResolver().applyBatch(
ContactsContract.AUTHORITY, operations);
}
Ok, mais mon problème est de trouver le bon contact et je ne trouve pas un champ qui me dit que le contact est dans un groupe déterminé. Pour ce que j'ai vu je dois regarder la table de groupe et obtenir l'id des personnes dedans mais j'échoue dedans: D ainsi ... comment est-ce que je fais correspondre la table 2? est-il un moyen de les rejoindre ?? ty – Andrea