Here is a test app (→ Designer: DefaultFileScope = Shared
)
with which a text file and an image can be copied from the assets to the shared storage (for devices with Android ≥ 10). This works neither for the text file nor for the image (regardless of whether storage permission was granted beforehand):
"Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied. Please enable ...
".
Note: With → Niotron the text file is copied to shared storage (without permission), but you need
READ
permission to read it. The image (foto.jpg
) can, however, be copied into the shared storage and also displayed from there (withoutREAD
permission, as it should be). Folders (which function as shared storage and images can be copied into) are:
/Download
/Documents
/DCIM
/Pictures
See here.
If you try to delete these files, however, you will get an error message (incorrectly):
"Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied. Please enable ...
".
Steps to test the app (especially on Android 10 and 11):
- Install and open the app.
- Deny permission.
- Click first button (deny permission).
- Check the CheckBox and click on the first button angain.
- Click on the third button (Copy bg.jpg to ...).
- Click on the fourth button (files ... exist?).
- Click on the last button (remove ...).
- Uninstall and reinstall the app.
- Grant permission.
- Continue with step 3 - 6: → same result.
Try also different folders (→ TextBox
).
Note:
If DefaultFileScope
was set to → Shared
, only READ
permission is declared in the Manifest and not WRITE
permission. But on devices with Android < 10 it must be possible to request WRITE
permission.
So, as I already said, READ
/ WRITE
permissions should be declared this way in the Manifest:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="28" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
This is the same app with → Designer: DefaultFileScope = Legacy
:
Repeat the above steps.
It should work only if READ
permission has been granted.
Important note:
If the text file or image already exists and you try to copy it again, the files are not replaced, but a new file is created (e.g.: 123(1).txt
). This causes the app to stop working after the app is uninstalled and reinstalled (because the text file is then not created by the app).