Working with shared folders, 28/09/21
@Program_maker
See my reply here API 30 workarounds v2 - #20 by anonwins
So the moment you re-install your app, say bye-bye to your writing capabilities of the files that you have saved in shared folders.
So my guide works only if you keep your current app installed (no reinstalling, no installing other version, etc). Of course without reading capabilities in shared folders none-soever. A good practice then would be to only work with files in ASD, and just EXPORT to a shared folder. Because the "exported" file cannot be accessed any more. (It can be overwritten or deleted though, until you reinstall the app). You can't read from the "exported" file at all.
Keep in mind you can't overwrite if you reinstall the app, so you should make sure the file doesn't already exist. For example, timestamp it: /storage/emulated/0/Documents/MyNewFile-1630121307.txt
or just use TaifunFile.Exists (it works even on reinstalled apps) and then save by another name if it exists.
All in all, when you "export" your file, you should forget about it. It's saved and out of your control.
Note also: because you can't read the "exported" file, you can't copy it back to ASD for working with it. So make sure you keep a copy of it in ASD from the beginning. So you can export another one easily.
ASD (Application-specific Directory)
TaifunFile can write, overwrite, delete
TaifunFile can check if file exists
File component can read, write
Shared folder (eg. /Documents or /Download)
TaifunFile can write
TaifunFile can overwrite or delete (but not if app is reinstalled, or if using another app)
TaifunFile can check if file exists
File component cannot read/write, or even see files
Extensions which don't rely on WRITE_EXTERNAL_STORAGE
permission can read files
*Where you see TaifunFile, it means also all extensions/components that don't rely on WRITE_EXTERNAL_STORAGE
permission. (TaifunMusicPlayer, Pro Camera, etc)
This table makes it obvious that you cannot work in shared folders. Things will break. But you can always work in ASD and export to shared. This makes sense. This is why the ASD exists.
Android tell you "here's your playground (ASD), do anything you want in there, i don't mind. but in the shared folders, you're not the boss. you can't just delete another app's things. you can't just edit another app's things. mind your own business in the shared folder. you wanna go crazy? get crazy in your ASD, buddy!"
For android, each version of an app is another app. Heck, even each installation of an app is another app.
Hope this little guide clears things. It's been a mess these days.
You see, this is good practice. Because in the shared folders, the user is the boss, not an app. You can't read/overwrite in shared folders, and that's good. This is privacy & security, and makes me happy to know my phone secures my data from being overwritten/deleted by weird apps.
Keep in mind that extensions like TaifunMusicPlayer can read files in shared folders. You can request a song to play. It's just that the file component is kinda broken now and can't read files in shared folder, but in theory, android allows it.
DefaultFileScope:Legacy
I just ran some tests using this option. It seems to enable file reading in shared folders using the file component. But if the file is created by another app, or another installation of the same app, then you can't read it using the file component. So it doesn't really help. You can't rely on it. Am I right, miss @Anke?