Hi, I just noticed this issue and I wonder what it might depend on:
I have access to 2 similar smartphones where the same app (published for internal testing on play store) on one device can write to
/storage/emulated/0/Downloads/
while on the other device crashes because (I guess) it can't write there.
The device on which it crashes, has the same crash running the app in giderosPlayer, which is "
attempt to index nil with 'write' ".
It can still write to /storage/emulated/0/Documents/ though so it's fine at this time, BUT this sounds like magic: both have permissions to write to external storage, and much more.
Comparing software info on the devices (both S20, one of those S20 5G) it appears that there is no difference between them: they have the same releases, patches and stuff.
Logcat says
package does not have legacy storage but that should be true for both devices, since it depends on the package itself. For reference:
https://developer.android.com/about/versions/11/privacy/storageAny ideas? Thank you!
Comments
So far I have been using https://wiki.gideros.rocks/index.php/Mediamanager:saveFile and the media library in general.
If you know the folder where you want to save to you can hard code it in the plugin it's easy but I don't know if the media plugin is still working
Just import lfs plugin and use as destination path a string pointing to Downloads or Documents path:
/storage/emulated/0/Documents/destinationfile.name
https://androidexplained.github.io/android/android11/scoped-storage/2020/09/29/file-saving-android-11.html
I am not sure this is implemented yet
+ https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)
As to why this works on one phone and not the other: do they have both a single user? as with multiple users the code may differ thus not work?
Even scoped storage shouldn't be an issue, because Documents folder is still accessible on the "crashing phone", while on the other phone Download still works fine.
It's magic..
I can access the Download folder with other apps and of course I enabled write permissions on external storage. There are still 50gb of free storage space, so I would rule out that reason. Not a big deal unless it's something that will happen again maybe on other phones.