I am usinge the ```Intent.ACTION_OPEN_DOCUMENT_TRE...
# android
t
I am usinge the
Copy code
Intent.ACTION_OPEN_DOCUMENT_TREE
to let the user choose a directory and get access to this directory. It works but unfortunately the access is only temporary when the user closes the app and opens the app again i need to open the directory picker again. Especially for development this is very unpleasent. Of course i could ask the user for MANAGE_EXTERNAL_STORAGE permission but Google do not want this anymore for normal apps. My app is just a video player. But i need access to the directory to load subtitle files.
😶 2
i
The docs tell you exactly how to persist access so you don't need to ask a second time: https://developer.android.com/training/data-storage/shared/documents-files#persist-permissions
t
Yes but in my observations this is only true for files not for directories. At least in my observations. Maybe i am doing something wrong. I also do not care about device reboot that is not important.
i
It also works for directories
yes black 1
t
Thank you for pointing me to the documentation i think i got it working 😄
🎉 1
But it looks like i have to call this
Copy code
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
ctx.contentResolver.takePersistableUriPermission(uri, flags)
even if i do not care about reboots. But than it works when i restart the app. Thank you very much
806 Views