When implementing a DocumentsProvider
, you can only extend access to files on disk that you already have access to. Adding a DocumentsProvider
doesn't give you any new access, so you probably don't need to implement one.
You can gain write access anywhere on an SD card by using the ACTION_OPEN_DOCUMENT
or ACTION_CREATE_DOCUMENT
intents that you mentioned. There is an ExternalStorageProvider
built into the system that has access to all SD cards, and it will gladly delegate write access to you once confirmed by the user through those intents.
Users may need to enable "Settings > Display advanced devices" to show the SD cards offered by ExternalStorageProvider
. Also, if you want to limit the user to interacting with local storage, you can set EXTRA_LOCAL_ONLY
.
As for (2), you can create new files outside your package-specific directory with ACTION_CREATE_DOCUMENT
, and you can select existing files with either intent. User-selected files can be deleted with DocumentsContract.deleteDocument()
.
And for (3), MediaDocumentsProvider
built into the platform currently does not extend FLAG_SUPPORTS_WRITE
for Photos, Videos, and Music.
Hope this helps. :)