Issue using Contact Group delete on Android

一个人想着一个人 提交于 2019-12-01 01:20:42

You don't need to add where clause saying that. If you wont to instantly delete items in database and not flag them as deleted, add this row to you URI.

mUri.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,"1").build();
//and then call your delete function with URI appended like this.
mResolver.delete(mUri,null, null);

that flag: CALLER_IS_SYNCADAPTER set to 1 will delete row instantly.

Hope this helped.

It was my miss:

When quering the existing records I had to add a where clause to denote that I do not want deleted=1 values, as the values are not delete instantly, they are flagged as deleted.

Cursor managedCursor = act.managedQuery(contacts, projection, 
                ContactsContract.Groups.DELETED + "=0", 
                null,
                ContactsContract.Groups.TITLE + " ASC");
        return managedCursor;

you can delete contact group using this

    private void deletaAllInGroup(Context context, long groupId)
           throws RemoteException, OperationApplicationException{
    ContentValues values = new ContentValues();         
    values.put(ContactsContract.Groups._ID, groupId);
    getContentResolver().delete(ContactsContract.Groups.CONTENT_URI,values.toString(),null);
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!