Is there a way to use the StorageActionFramework ACTION_OPEN_DOCUMENT intent to request info for a specific file? More specifically, I have a URI for a particular file, which I obtained from MediaStore. I would like to find out if it has write access and, if so, delete it. Further, I'd like to do this without any UI (none is needed in this particular context).
The documentation says how to do it for a class of files using intent.addCategory (Intent.CATEGORY_OPENABLE), for example. And to restrict it to a certain type of file, intent.setType ("image/*"), for example. But I don't see anything to restrict it to a specific file.
Also, I realize that once you receive a set of files from the StorageActionFramework, you can view properties for individual files.
It appears that if I could use ACTION_OPEN_DOCUMENT to get the SAF's URI, I could then use DocumentsContract.deleteDocument() to delete it.
More Context
In my situation, the user has invoked the camera app from within my app and taken one or more pictures. My code then queries the MediaStore to determine the file name(s) for the new image(s). Then I desire to move the file(s) to a directory specific to my app. This works fine for files located in "internal" and "external" storage but not for removable storage.
In the long run, this solution is inadequate as clearly it will use to much permanent storage (although that is mitigated by the fast pace which storage size is increasing). However my app does need control over image files which are taken via the app and, thus, leaving them on the removable storage will potentially break the app.
Another complicating factor is the lack of an Android API for taking multiple photos and saving them to a prescribed location. There is such an API for taking a single photo but that will not work for my application. Thus, I am relegated to letting the camera app save its files where it wants to and then moving them afterward.
Some other apps simply make a copy of photos and store the copy in a private directory. I could do that but that exacerbates the storage problem even more. The long term solution will probably be using cloud storage in combination with a local private cache.
No. For starters, the Storage Access Framework has little to do with files.
The closest thing that would fit the overall structure would be if you could supply a starting
Uri, to allow users to choose and open a document nearby that one. That would be a nice feature but is not supported.No.
CATEGORY_OPENABLEmeans that theUrithat you get back should work withopenInputStream(),openOutputStream(), and related methods, and that aquery()on theUrishould be able to return theOpenableColumns. It has little to do with files.That limits the content to a particular MIME type (or wildcard). It has little to do with files.
You might have write access to change the contents, via
openOutputStream(). I am not aware that you have a means of deleting the underlying content.The only reason to use
ACTION_OPEN_DOCUMENTis to show a UI, to allow the user to choose a piece of content.Since there is no requirement for a camera app to update the
MediaStore, this does not seem like it will be especially reliable.Since there is no requirement for a camera app to allow the user to take multiple photos in succession, this does not seem like it will be especially reliable.