It's as simple as this:
It's as simple as this:
This is correct to save a text file with Android > 9 in the subfolder
/Download of the
But this subfolder (
/Download) does not exist (in the
ASD). So you must create it beforehand using e.g. the
yes, but my goal was to save it on /storage/emulated/0/Download/
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 http://ai2.appinventor.mit.edu/reference/components/storage.html#File
SaveFile( text , fileName )
Saves text to a file. If the
fileNamebegins with a slash (
/) the file is written to the sdcard (for example, writing to
/myFile.txtwill write the file to
/sdcard/myFile.txt). If the
fileNamedoes 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/datato 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)
Did you test also after building the app?
That would be nice, but I don't think so.
Actually that's the purpose of file scope Shared...
Saving files in the shared storage seems to be intended / to work only for media files.
@ewpatton might want to comment on this
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).
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 http://puravidaapps.com/file.php and copy the file from the ASD to the destination directory... however this will stop working after App Inventor targets SDK30...
I am developing app. I have a pdf file. how to upload it. can someone help me / guide me.
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.