I had an application in the previous versions that wrote electrocardiogram data files in a predefined folder and users could easily access those files from outside the app, and export them to a PC for example.
In the latest version which prevents writing to the device's memory, I write files to the ASD.
But this directory is not easily accessible by the users. I can use file explorers such as "EStrongs" and it finds the file by deep search, but this is not user friendly.
Is there a way to design an "export" button that opens the ASD folder and user selects the files (with an option to select all) then copies the files somewhere else, or shares the files through whatsapp etc.
An option to delete the exported files to clear the ASD directory would be desirable, please!
for the Download folder this should work
/Download/ECG_Save/yourFilename.png
Set the DefaultFileScope in the Screen properties to App. .
EDIT:Should of course be set to Shared to store something in shared storage... however as @Anke mentioned, you have to use Legacy because of a bug...
To store in the Documents folder try
/Documents/ECG... or
/Document/ECG...
Set the DefaultFileScope in the Screen properties to App .
In this way the application creates a folder named "Documents" in the ASD, then writes inside it!
Changed the file scope to "shared" and "legacy"; did not work.
To save an image with the Canvas component in one of the Shared folders directly you must set DefaultFileScope to Shared or Legacy.
Otherwise set it to App, save the image in the ASD and then move it to one of the Shared folder using the File component or one of the File extensions from @Taifun or @vknow360.
Correct, the DefaultFileScope is essentially responsible for two things:
Where are files, created with components that can save something (ie e.g. Canvas), stored.
Which permissions are declared on which Android versions in the Manifest.
To store files directly in the Shared folder /Documents with the Canvas component, DefaultFileScope must be set to Legacy, as this is the only way to declare both storage permissions in the Manifest. On Android < 11 both permissions are required. Unfortunately with AI2 also incorrectly on Android 11+. I've mentioned this bug countless times.
Yes, this is another bug with the File component, that I also mentioned some times. But anyway, you need to set the DefaultFileScope to Legacy as I said before.
Your question was to save something using the canvas... so you should use the canvas for your tests... sorry, my previous answer about the default file scope was wrong, I corrected it meanwhile...
testing the file component to save some text will not help for your purposes...
Thank you so much. It worked. But I am totally confused.
At 1st installation, it saved without difficulty. but at later times, it could not save. Tried several times, looks like randomly working.
I am very close to give up!
As I wrote, you must delete the file before testing with the APK and vice versa.
Because if you first saves the (non-media) file with Companion, the compiled app (APK) cannot overwrite this file because it was created by another app (Companion).
I don't use companion. I test on my phone. I uninstall the app, delete the file and folder already is created, delete the downloaded apk, then again compile the project...