We have an app that allows users to, among other things, download files and store them locally. To provide greater access to the files (say for example, manual backups), the files are downloaded into an app specific folder in the Download directory.
Till Android Q, the app could simply use the File API to check if the file exists locally and update the UI accordingly. However, since then we've shifted to using the Mediastore API. However, one of the problems faced by users is loss of access to the downloaded files after a reinstall. After a reinstall the app has no way of knowing if a previous install had files left over. It can never properly manage the folder.
The scoped storage documentation says SAF is the way to go give apps full access to read and write to folders. Is there another way? If we are to use SAF, how do we need to request the permission every time the user opens the app? Is there any way to persist the file
schema URI that is returned? There is little documentation for this use case (either that or we didn't find any).
Thanks.
For Android 10 devices request legacy external storage in manifest file and you have File access to Download folder as usual.
For Android 11 devices the Download folder is readable in the old way and even writable. No need for media store.