I have an application that uses the save function of the drawing component "canvas", as a method to create a folder in the root directory of the mobile.
It has been working well for months, but when I recompiled the application (without having modified anything), it has stopped working on my mobile with Android 10, however when installing the application on another mobile with Android 4.4 it works. I have tried many things to fix it, but there is no way. I really appreciate if someone can help me.
I have created a small application to test the failure separately. Attached screenshots of the blocks.
If you need more information, tell me.
Thank you very much for your response. Now I can understand where the problem comes from.
The alternative solution is not very clear to me, but I have not managed to create a folder in the root directory with it. If you could explain better how to do it, I would appreciate it.
I need to save the file in a different folder than the one assigned by default, since I need the files to be preserved even if the application is uninstalled.
I have seen that the Kodular canvas does not give me this problem. But I can't import the project in kodular as it is very big and it gives me various errors.
you should not create folders anymore in the root directory
use the application specific directory already now to avoid problems in future
use the legacy mode of the file component but be aware, that starting from Android 11 you will not be able to use this anymore, from the release notes
Implement LegacyMode for File component (#2269)
Android 10 uses a new file model that prevents writing to arbitrary locations on external storage (colloquially, /sdcard/). People should migrate their files to app-specific storage, which is what the File component uses by default on Android 10. Checking the LegacyMode option will let you read files in the old locations, but will fail once App Inventor targets Android 11 (summer 2021). This has no effect on Android versions prior to Android 10.
Hello, I return to this topic, since I have problems with the "share" component.
The "share" component has not been updated to API 29 in the same way as the "file" component.
This creates problems for me when saving a file and then sharing it, since it does not read the same path with Android ≥10 devices, as Android ≤ 10.
One solution would be for the "share" component to point to the ASD (application specific directory), as the "file" component does. (But this should be changed by the appinventor programmers.)
On the other hand, if this is not solved, I need to know how I could identify the Android version of the device, to create solutions by programming based on the version.
Postscript: I think it would save problems if the "file" component and other components that have been updated to API 29 work the same way for all versions of Android and all read from the same path.
Thank you very much if someone can help me.
I attach some screenshots of how each code currently works with each version of Android:
I've tried testing it on my Android 10 device and it won't let me install the app.
On a mobile with Android 4.4 the file path directions fail. (In development mode it works for me with the path: file: ///sdcard/AppInventor/assets/deviceVersion.html), in normal mode, I have not been able to find the path of the html file.
I was afraid of that on Android 10. Before packaging the app, use the production path should work.
file:///android_asset/deviceVersion.html . This fails on Android 4.4? and 10? You may still able to get this to work in the compiled app by requesting READ_EXTERNAL_STORAGE Sorry Isaac. I do not have an Android 10 to test. The example builds fine on an Android 8.1; did you change development to false before you attempted to build?
There must be a way to get an Android 10 to read files in the Media.
Note that the version number of the current platform can be retrieved by using the PlatformVersion property of the Screen component. This will return the user-facing version number as a string, such as "10.0" or "8.1". This property is available on both Android and iOS.
But after doing several tests, I see that I can have problems with the previous versions of android 10 if I want to save the files in the root folder of the application.
I cannot save the files in the root directory with the extension "call AplicationSpecificDirectory" from Taifun on a device with Android 4.4.2
I was hoping that these blocks that I attach you save in the file at: /storage/sdcard0/Android/data/appinventor.ai.bulone6868.test/files/a.txt
But it saves it in:
/storage/sdcard0/storage/emulated/0/Android/data/appinventor.ai.bulone6868.test/files/a.txt
So I think the simplest thing in my case (for now) will be to save the files in the root folder for Devices smaller than Android 10 and in the application folder for those older than Android 10. (In both cases I have created another folder to have the files sorted)