GitHub user breautek added a comment to the discussion: Persistent storage

API 29 is kinda special. I am kinda surprised that it reports a permission 
denied error though still, but I'll explain what is probably occurring.

First, `requestLegacyExternalStorage` is only honoured if you're targeting API 
29 or lower. Starting with API 30, it is forcefully enabled and that setting is 
ignored. This means `requestLegacyExternalStorage` is not usable if you plan on 
deploying to the Google Play store. The flag was introduced when SAF (Scoped 
Access Framework) was introduced in API 29. But at that time you could opt out 
of SAF and get the old API 28 and earlier behaviour on API 29 to give 
developers a good amount of time to test and make changes to their 
applications. It was always documented that the setting will be ignored in a 
future target SDK, which that occurred on API 30+.

Under SAF, you're expected to use the 
[MediaStore](https://developer.android.com/reference/android/provider/MediaStore)
 APIs to access the external filesystem (that is the `/storage/emulated/...` 
path and/or `/sdcard/...` path) and Android disabled access to these paths with 
the `File` APIs (which is why `cordova-plugin-file` uses). Specifically on API 
29, using the Java File APIs to access the external storage is not possible.

In API 30, they introduced something called 
[FUSE](https://source.android.com/docs/core/storage/scoped#using-scoped-storage-with-fuse)
 which enabled file APIs once again, although with several limitations.

Because API 29 devices lacks FUSE, it might be why you're unable to list or 
explore the contents of `/storage/emulated/...` even in the file explorer. If 
you're using a `Google Play` image for your emulator, you might want to try the 
AOSP image instead which would have more relaxed security policies allowing you 
to be able to test easier. If that does work, it does indicate the ability to  
explore the content on retail devices will be limited.

GitHub link: 
https://github.com/apache/cordova/discussions/497#discussioncomment-10761743

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to