Is this so (is "Legacy" different in App Inventor) ? According to the documentation, Legacy gets ignored when targeting Android 11+
Is this so (is "Legacy" different in App Inventor) ? According to the documentation, Legacy gets ignored when targeting Android 11
I'm talking (and I think the OP as well) about the FileScope.
This has nothing to do with "requestLegacyExternalStorage
". You have no influence on this within the app anyway.
As I understand it, there shouldn’t be any problems as long as the app targets Android 10 (API 29), which is currently still the case with Kodular and AI2 (at least until the end of July 2021). I think this is a general warning about...
So as I said, FileScope = Legacy
works on all Android versions.
OK, two different things then
Hi,
Here is some of the blocks you demand, Anke
Building the system (write a file to Testsystem)
Read the file into the system subsequently
I don't know of these 'printscreen' pictures gives anything, but you say, that scope 'Legacy' (and scope *APP') works on all phones (only on my phone the scopes works as I describes, apparently)
Here is some of the blocks you demand, Anke
I recommend you to make it as easy for others to be able to help you ...
So post a simple test aia (as small as possible!) and the relevant blocks.
You try to read from the Private directory (internal storage) since you set FileScope = Legacy
.
You should learn some basics first, see e.g. here:
From an Android point of view there are an → Internal Storage and an → External Storage . 1. Internal Storage The Internal Storage can only be accessed with a rooted device. 1.1 The app package is saved in /data/data/<packageName>/ In order to be able to debug your app, AI2 saves the assets for → Companion on devices with Android ≥ 10 (API ≥ 29): /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/ Android < 10 : /storage/emulated/0/Android/data/edu.mit…
By the way, this part is no longer up to date:
I will make a simple aia file and when it's ready, I will let you know
Per
So as I said,
FileScope = Legacy
works on all Android versions.
still confused, the AI2 documentation says this:
- Legacy: Files will be read from and written to the file system using the App Inventor rules prior to release nb187. That is, file names starting with a single
/
will be read from and written to the root of the external storage directory, e.g.,/sdcard/
. Legacy functionality will not work on Android 11 or later.
Of course, you cannot write / read to / from
- the root directory or
- an arbitrary (sub)folder
of the external storage on Android 11+. But you can write / read to / from one of the Shared
folders using FileScope = Legacy
(also on Android 11+).
These Shared folders (for non-media files) are:
/Documents
/Download
of course
Of course, you cannot write / read to / from
- the root directory or
- an arbitrary (sub)folder
but you can do this with FileScope = legacy on Android less than 10 ?
In which case, does your statement:
FileScope = Legacy
works on all Android versions
apply ? It does for the /Documents and /Download directories but not for everywhere.... ?
Does Legacy then work in the same way as Shared
for Android 11+ ?
I am not being facetious, I really am trying to understand how the various filescopes work for Android 11+
The guidance (from Android) is that we should be targeting Android 11+ practices in our apps, regardless of the version the app is used on.
I think, the confusion are the 2 different file scopes we have
- in the Screen properties the DefaultFileScope and
- the file scope of the file component
as @Anke already pointed out "endless times" , btw. last time was here
Both storage permissions are required on all Android versions. Unfortunately incorrectly even on Android 11+ (meaning it should work on Android 11+ without any storage permissions). In order for both permissions to be declared in the Manifest on all Android version (even on Android 11+), → DefaultFileScope must be set to → Legacy in the designer. Note: WRITE permission is no longer avialable on Android 11, but is still wrongly needed to make it work on Android 11+ devices. Check this app (e…
unfortunately up to now without feedback from @ewpatton, still looking forward to it...
what we have to do currently (as far as I understand it) to get "it" running on all Android versions is
- in the Screen properties set the DefautlFileScope to
Legacy
to get the correct permissions in the manifest and - set the File scope of the file component to what you need in your app, for example
a) if you like to store/read to/from shared storage, you set File Scope toShared
b) if you like to store/read to/from ASD, you set file scope toApp
Taifun
Does Legacy then work in the same way as
Shared
for Android 11+ ?
Yes, except for the small difference that when FileScope = Shared is set, the /
at the beginning is ignored, so the file is always stored in external storage and not in the Private dir of internal storage (as is the case with FileScope = Legacy is if there is no /
at the beginning of the path).
Otherwise (i.e. if there is no /
at the beginning of the path) these two scopes work identically.
what we have to do currently (as far as I understand it) to get "it" running on all Android versions is
- in the Screen properties set the DefautlFileScope to
Legacy
to get the correct permissions in the manifest
to get correct permissions
To get the required permissions. These are indeed the correct permissions on Android < 11, but on Android 11 these are the incorrect permissions because
- on Android 11+ there is no longer
WRITE
permission and - both permissions (
READ
/WRITE
) are not needed at all (for theShared
folders).
Since AI2 decided to declare
requestLegacyExternalStorage=true
in the Manifest (which is only ignored on Android 11+), the storage permissions should be declared basically (always) in all Scopes (DefaultFileScope and FileScope) this way:<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
Note: If
DefaultFileScope
and theFileScope
are both set to App, files are saved in the ASD with the File component. But on Android < 4.4 (< API 19, KitKat)READ
&WRITE
permissions are required.In order for these permissions to both be declared in the Manifest, the default settings of the
File
component must be changed and both permissions must be enabled in the designer. So there is no (recognizable) reason why this option (ReadPermission, WritePermission) exists in theFile
component at all. Because both permissions are always required on Android < 4.4.
But if you then want to copy/move a file from the ASD to one of the Shared folders,
WRITE
permission is incorrectly requested even on Android 11+. This permission is
- no longer available on Android 11+ and
- is not required on Android 11+.
Can anyone make this even clearer? I wouldn't know how!
When even PUs (and apparently even the MIT team ) seem to have trouble understanding all this scope stuff, how will it be with the others?
Can anyone make this even clearer? I wouldn't know how!
This is why I have generally been pushing users to saving/storing/retrieving files in/to/from the ASD, which seems to be the most reliable and straightforward location, and to then work from there - either to attempt a copy/move to some shared storage, or just get the file off the device online somewhere.
This is why I have generally been pushing users to saving/storing/retrieving files in/to/from the ASD
Yes, but even with that, on Android < 4.4 (with the default settings of the File
comp.), you'll have permission issues, as I explained earlier. Only not if both storage permission are enabled in the File comp. (in the designer).
This is only irrelevant for Kodular, because the
minSdkVersion
is19
(Android 4.4, KitKat) there. But with AI2 theminSdkVersion
is7
(Android 2.1, Eclair).
on Android < 4.4 (with the default settings of the
File
comp.), you'll have permission issues
sigh....
But with AI2 the
minSdkVersion
is7
(Android 2.1, Eclair).
Which really shouldn't make much sense.
Who on earth is still using Android 2.1 (→ Oct 2009)?