add a helper function for deleting a contact group

This commit is contained in:
tibbi 2018-03-18 20:40:55 +01:00
parent c3a148282f
commit 4294228bfd
1 changed files with 14 additions and 0 deletions

View File

@ -399,6 +399,20 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
return null return null
} }
fun deleteGroup(id: Long) {
try {
val operations = ArrayList<ContentProviderOperation>()
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? { fun getContactWithId(id: Int, isLocalPrivate: Boolean): Contact? {
if (id == 0) { if (id == 0) {
return null return null