copying works, but reading the file not... see logcat output
Default scope of the app is Shared
the correct path to read from would be /storage/emulated/0/Download/WooHoo.txt
trying to copy the file again... and if the file exists, then it should be overwritten... the Exists block returns true, but the Delete method fails to delete the file in the shared directory, logcat output:
as it seems to be, the Delete method tries to delete the file in the ASD but not in the Shared directory...
then the Copy method copies the file correctly to the shared directory, however because the file already exists, file WooHoo (1).txt will be created
b) using the apk file
using the Exists method for the Shared storage results in the error message
going further I created a small extension, which adds READ_EXTERNAL STORAGE into the manifest...
this helped for the Screen.Iniitialize event, but now the Copy method failed.because of missing WRITE permissions...
I created another small extension, which adds WRITE_EXTERNAL STORAGE into the manifest...
this unfortunately did not help too much, because after examining the manifest with APK Editor Studio we get a restricted permission like this <uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
remember, I'm using an Android 11 device for my tests...
but after modifying the manifest and changing the permission to only <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
the apk was able to copy the file from the assets to the shared directory
which means, if the user likes to copy something to a shared directory, WRITE_EXTERNAL_STORAGE permission still is required without maxSdkVersion="29" restriction!
however reading the file from there also failed, same as in the companion app... tries again to read from ASD rather than the shared directory...
READ / WRITE permissions are only declared in the Manifest (for devices with Android 4.4 up / API 19+) if DefaultFileScope is set to Legacy. I already mentioned this several times. See e.g.: → here or here.
yes, I have seen your contributions... but I did not understand, what you want to say... are the permissions ok as they are from your point of view or is there still some bug?
ok, my error previously was the scope of the file component... I have overseen, that this exists, too... setting it to Lecacy now...
copying to Download and reading from there works now...
the Delete method fails to delete the file in the shared directory if it already exists... probably this is not possible anymore? Because as the file already exists, file WooHoo (1).txt will be created
trying to copy to Documents fails with the following error
as you can see, a Documents folder exists:
probably it would make sense to provide a method, which returns all available shared directories?
trying to copy to a shared folder, which does not exist results in the companion app to crash, logcat output:
Yes, I already tested it on the AI2 test server and with Niotron. It only works with Niotron.
See also here:
I built the same project on the AI2 test server and it works with the folder /Download, but e.g. not with /Documents. (No issues with that on Niotron.)
Hi @Atom_Developer, it seems to be, you fixed another bug in the new file component...
what about sharing your solution to the MIT App Inventor team?
also in case you were able to fix other bugs in the file component, it would be great to share them...
I'll take a look, but I thought I had read somewhere that the files table was a read-only view of all files, so I wasn't expecting to be able to update it.