Open catabriga opened 1 month ago
Doesn't scoped storage make this impossible since Android 11? The user needs to grant explicit permission for every folder to be readable (let alone writable) outside of the app-specific private folder.
Doesn't scoped storage make this impossible since Android 11? The user needs to grant explicit permission for every folder to be readable (let alone writable) outside of the app-specific private folder.
Yes. Actually Google's latest take on this is that Android presents a selection dialog to the user and only returns a path to the app which points to the media file selected by the user. This is asynchronous and the app needs to wait for the user to make their selection.
See https://developer.android.com/training/data-storage/shared/photopicker#add-dependency for details.
Doesn't scoped storage make this impossible since Android 11? The user needs to grant explicit permission for every folder to be readable (let alone writable) outside of the app-specific private folder.
Both folders I mentioned are app specific: /storage/emulated/0/Android/data/org.godotengine.gamename/files/Pictures /storage/emulated/0/Android/media/org.godotengine.gamename/gamename
They are specific to the app org.godotengine.gamename. The difference is that in the second case it belongs to "media" and that makes it visible in the gallery. As I mentioned, I tested this both on Android 11 and 14, no extra permission is necessary and the image saved using Image.save_png method is visible to the gallery if I use the path with /media/ on it. That path however is not the one returned by get_system_dir.
Tested versions
Tested on 4.2.2
System information
Tested on Android 11 and Android 14
Issue description
Calling OS::get_system_dir(dir = SystemDir::SYSTEM_DIR_PICTURES, shared_storage = false) on Android returns the following path: /storage/emulated/0/Android/data/org.godotengine.gamename/files/Pictures
This is not a very useful location, as files stored in this location are not visible in the phone's gallery and are in general not accessible for the user.
If instead a path on media is used, the pictures are available in the gallery and are accessible to the user. I am currently hardcoding the following path and it works correctly: /storage/emulated/0/Android/media/org.godotengine.gamename/gamename
I'm don't have much knowledge in Android, but I think this should be the path returned by the get_system_dir function.
Steps to reproduce
Print the returned value of OS::get_system_dir(SYSTEM_DIR_PICTURES) in an Android phone.
Minimal reproduction project (MRP)
N/A