Use new permissions in Android to allow file access to /storage/emulated/0/Android/ and /sdcard/?

I think starting in Android 9 or 10 you were given a permissions API to grant file access to normally locked directories and as of now the app still requests root access when it doesn’t need to anymore.

I think there is some confusion here. /sdcard/ is the same as /storage/emulated/0/ and this is the internal storage on Android. /storage/emulated/0/Android/ is a folder that contains three subfolders - data, media, obb - and out of these, only media is accessible to 3rd party apps. If you investigate the subject more, it appears that there exist hacky ways that some apps utilise to access to other two, but Syncthing doesn’t do that, so only media can be accessed by it.

On the other hand, when it comes to syncing files located on actual external SD cards, then this is already possible by granting “all files access” but only on Android 11 and newer (and Android 4.3 and older, but the current version of the Syncthing app doesn’t support those any more).

Allowing access to the data and obb directories is, indeed, as simple as granting the “All files access” permission that you mentioned. I was (and still am) capable of accessing those directories in my file system. It just requires that the application which needs access open the file system prompt within the afforementioned folders rather than within the SD card.

The “all files access” permission was added in Android 11. Syncthing already utilizes this where supported. Where supported by the platform (Android OS, file picker etc) you get popups to grant access to relevant folders:

All of this only works on Android 11+.

2 Likes

Yeah, that’s what I meant. I just didn’t know what version it was added.

Other apps use that to grant permission to data and obb as well, so why can’t SyncThing?

Syncthing probably could but someone would need to first examine how (some) file managers manage to do it and then write the required code. As the Syncthing app is in maintenance mode, I wouldn’t hold my breath for a quick fix.