I’m using a custom ContentProvider. For querying, there is a CancellationSignal (API 16+) which can be used to cancel a previous call to query().
My question: How can I archive that with delete()? For clarification, my custom provider manages files on SD card, and so I want to be able to cancel delete operation inside my provider.
I solved this with a simple solution.
For example, for every call to
query(), we put a parameter pointing to the task ID, and use a SparseBooleanArray to hold that ID, like:Usage:
To query:
To cancel:
For a complete working solution, have a look at android-filechooser.
The advantage is you can use this technique in Android… 1+ and for other methods such as
delete(),update()… While CancellationSignal is only available in API 16+ and is limited to onlyquery().