Reputation: 325
I want to store my app configuration in a JSON file, that user can edit. Where can I place it to avoid requesting full storage access permission? I'm targeting Android 11 and higher.
Upvotes: 0
Views: 26
Reputation: 1007474
One option is to use ACTION_CREATE_DOCUMENT
to let the user decide where to put the JSON. When you get the Uri
back, you can call takePersistableUriPermissions()
on ContentResolver
to have long-term access to the content identified by the Uri
. You can also use ContentResolver
and its openInputStream()
and openOutputStream()
methods to read and write the JSON with your favorite JSON parser.
Another option is to store the JSON in the Documents/
or Downloads/
directories using ordinary file I/O. You have the ability to write files there, plus the ability to read files that you wrote.
Upvotes: 0