From 4294228bfd4a0e6f9508e614688ec9b073802c3b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Mar 2018 20:40:55 +0100 Subject: [PATCH] add a helper function for deleting a contact group --- .../contacts/helpers/ContactsHelper.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 8aa8bd08..dd0abc9c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -399,6 +399,20 @@ class ContactsHelper(val activity: BaseSimpleActivity) { return null } + fun deleteGroup(id: Long) { + try { + val operations = ArrayList() + val uri = ContentUris.withAppendedId(ContactsContract.Groups.CONTENT_URI, id).buildUpon() + .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") + .build() + + operations.add(ContentProviderOperation.newDelete(uri).build()) + activity.contentResolver.applyBatch(ContactsContract.AUTHORITY, operations) + } catch (e: Exception) { + activity.showErrorToast(e) + } + } + fun getContactWithId(id: Int, isLocalPrivate: Boolean): Contact? { if (id == 0) { return null