It's as simple as this:
This is correct to save a text file with Android > 9 in the subfolder /Download
of the ASD
.
But this subfolder (/Download
) does not exist (in the ASD
). So you must create it beforehand using e.g. the TaifunFile
or FileTools
extension.
Hi Anke,
yes, but my goal was to save it on /storage/emulated/0/Download/
Rui
This will no longer work with the coming update (targetSdkVersion = 30
)
(which should actually already be available from Aug).
for me this looks correct for the current version of App Inventor, see also the documentation Storage
SaveFile( text , fileName )
Saves text to a file. If the
fileName
begins with a slash (/
) the file is written to the sdcard (for example, writing to/myFile.txt
will write the file to/sdcard/myFile.txt
). If thefileName
does not start with a slash, it will be written in the program’s private data directory where it will not be accessible to other programs on the phone. There is a special exception for the AI Companion where these files are written to/sdcard/AppInventor/data
to facilitate debugging.
is the documentation not up-to-date anymore?
probably we have to wait for the new version for storing to a shared directory again?
as far as I understand, this will still work in the new version... /Download
is a shared directory, so in the new version of the file component you will have to use fileScope Shared
together with the path /Download/contactos.txt
, see also the design document File component - save (all types of) files in the Private dir (→ internal storage) - #8 by ewpatton
Taifun
Did you test also after building the app?
Taifun
Schön wär's.
That would be nice, but I don't think so.
Actually that's the purpose of file scope Shared...
Taifun
Saving files in the shared storage seems to be intended / to work only for media files.
Yes I did.
No matter what path I indicated for the file, If it started with a "/" it would always be appended to ASD (/storage/emulated/0/Android/data/appname/files).
Rui
And by the way, the SDK level of this device is 29.
a device does not have a SDK level, a device runs an Android version, and it looks like you are trying to say, your device is running Android 10...
App Inventor currently targets SDK 29 an will very soon target SDK30... this is independant on the Android version your device is running... and this upgrade will change a lot especially regarding storing files... I hope, that we then will be able to store a text file in a shared directory again, but as you have seen in the discussion with @Anke, I might be wrong...
as a temporary workaround you can use the file extension App Inventor Extensions: File | Pura Vida Apps and copy the file from the ASD to the destination directory... however this will stop working after App Inventor targets SDK30...
Taifun
Hi,
I am developing app. I have a pdf file. how to upload it. can someone help me / guide me.
Thanks
Hi.
The simplest way is to do it here:
Your file will be distributed with the App.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.