How to store text file on appinventor

2,388 views
Skip to first unread message

Francesco Caló

unread,
May 22, 2016, 6:27:03 AM5/22/16
to MIT App Inventor Forum
Hi, i'm working on a quiz app. I have two text files on my notebook, one for the question and the other one for the answers. I need to store it on the AppInventor and, obviously, on the user smartphone. this files then will be used in lists and in other components of block editor so i need to know ho to get their value.  
thank you for the help
Francesco
Cattura1.PNG
Cattura.PNG

Tim at Loddon

unread,
May 22, 2016, 7:23:49 AM5/22/16
to MIT App Inventor Forum
As just answered for someone else :)

Everything you need to know is written here:


Text files created with "File" have slightly different file paths depending on whether you use the AI Companion or a built app.

Best thing to do is to create a set of "development test" blocks so you can operate in either environment.

The default is to save the file in the private storage area of the phone, or as an asset, which means you won't be able to see it with your Android File Manager. Save the file to a "public area", then you will be able to see it, if you want to.

Francesco Caló

unread,
May 22, 2016, 9:22:09 AM5/22/16
to MIT App Inventor Forum
do you mean that i have to follow this procedure? https://developer.android.com/guide/topics/data/data-storage.html#filesInternal
i did not understand at all how can i proceed. 

Taifun

unread,
May 22, 2016, 12:02:51 PM5/22/16
to MIT App Inventor Forum
 I have two text files on my notebook, one for the question and the other one for the answers. I need to store it on the AppInventor

upload the 2 files as assets into App Inventor and then read them from the assets using the file component like this //domande.txt


ReadFrom(text fileName)
Reads text from a file in storage. Prefix the filename with / to read from a specific file on the SD card (for example, /myFile.txt will read the file /sdcard/myFile.txt). To read assets packaged with an application (also works for the Companion) start the filename with // (two slashes). If a filename does not start with a slash, it will be read from the application's private storage (for packaged apps) and from /sdcard/AppInventor/data for the Companion.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Francesco Caló

unread,
May 22, 2016, 2:10:56 PM5/22/16
to MIT App Inventor Forum
thank you, solved
Reply all
Reply to author
Forward
0 new messages