java - ContentResolver delete multiple -
i know record can deleted this:
getcontentresolver().delete(events.content_uri, events._id + " =? ", eventid);
where eventid string array
containing, in case event's id. in case, don't want delete 1 event, multiple. i've got array of eventids containing multiple eventids. of course loop through array , delete events 1 one, possible delete them using 1 call?
try code,
arraylist<contentprovideroperation> operationlist = new arraylist<contentprovideroperation>(); contentprovideroperation contentprovideroperation; (/*loop on arraylist*/) { contentprovideroperation = contentprovideroperation.newdelete(events.content_uri).withselection(events._id + " =? ", new string[]{yourid}).build(); operationlist.add(contentprovideroperation); } try { getcontentresolver().applybatch(contract.authority, operationlist); } // catch exceptions
more info: contentprovideroperation
Comments
Post a Comment