Question about Document Provider (Storage Access Framework)

I’m working on an Audiobook Player that connects to Nextcloud. The idea is to store the audiobooks on a nextcloud server, then use the app to “download” the audiobooks to the device.

Right now though, I’m a little hung up on how to properly manage the downloads. I can easily enough request the files through the document provider api for nextcloud. Nextcloud will then download the files and store them on device. The problem I am having is I don’t know how to allow users to delete the books from their device.

After nextcloud caches the files, I copy them to App storage. The problem with this solution is the nextcloud cache is still intact. So every time a user downloads a book, it’s going to take up twice the storage, unless they manually delete the files from within the nextcloud app.

I would like to either be able to delete the nextcloud cache from within my app, or prevent nextcloud from retaining the files- it downloads the files to a temporary location, then hands the files over to me, and it clears the cache itself.

Any pointers in the right direction would be greatly appreciated!
Thanks!

Any progress on that app? I’ve been using cloud beats and it lacks in some areas.