I've had problems before where naively writing a file on my device, changes to it weren't visible when it was plugged in to my computer over USB.
Perhaps you did not index the resulting content in the MediaStore
.
But is that how I write my application to engage storage?
I do not know what "engage storage" means.
Or just for writing new kinds of storage?
I do not know what "writing new kinds of storage" means.
The Storage Access Framework offers three Intent
actions for common scenarios:
ACTION_OPEN_DOCUMENT
, which is similar to the "file open" dialogs from other platforms
ACTION_CREATE_DOCUMENT
, which is similar to the "save as" dialogs from other platforms
ACTION_OPEN_DOCUMENT_TREE
, which is similar to the "choose directory" dialogs from other platforms
However, the Storage Access Framework is designed around storage providers, not files, to provide seamless access to network shares, cloud storage providers, and anyone else that wants to provide the "back end" support for storage. Hence, you work with Uri
values, using ContentResolver
and DocumentFile
for getting streams, navigating document trees, and so forth. You do not work with files directly, in part because none of the content necessarily is stored in files on a filesystem, at least in a place that you can access.
What's the straightforward way to read and write files that works?
Work with internal storage or external storage.