Hi, good afternoon.
I have a very basic question - If I have something like this:
Where must the file be placed in order to be read?
Best Regards,
Rui
Hi, good afternoon.
I have a very basic question - If I have something like this:
Where must the file be placed in order to be read?
Best Regards,
Rui
from the documentation Storage
ReadFrom( 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 thefileName
with//
(two slashes). If afileName
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.
just use the SaveFile method to save it there
but probably you like to upload your file in the Media section into your project (assets) and read it from there? just use //teste.txt
then
Taifun
The text file is saved in the privateDir
(internal storage):
/data/user/0/<packageName>/files/teste.txt
See also here:
Hello Anke.
If I connect the phone to my PC via USB, am I able to reach that folder?
Best Regards,
Rui
No, only with a rooted device.
Hello Anke.
When I connect my phone to my computer, there is a folder called Android. Imagine that I wanted to read a file inside "Android/data/packageName/files"...what do I need to put in the file name in order for it to be read from that folder?
Best Regards,
Rui
See here:
So, if I understood correctly, this folder:
/storage/emulated/0/Android/data/packageName/files/
is the one that is shown when I connect my Phone to my PC via USB as:
/Android/data/packageName/files
?
Both paths are identical...
The first is a full path, the second a relative path on the internal (emulated) sdcard...
You might want to elaborate, what exactly you are trying to do...
Taifun
1. This path is an → absolute path:
/storage/emulated/0/Android/data/packageName/files/
2. and this path is a → relative path:
/Android/data/packageName/files
Some components need a relative and others an absolute path.
3. And on top of that, some components or Android versions require a → full path:
file:///storage/emulated/0/Android/data/packageName/files/
I would recommend these 3 terms to distinguish the paths:
/Download
/storage/emulated/0/Download
file:///storage/emulated/0/Download
Hi, I'm developing a Contacts App, that reads the contacts from a CSV file.
But I don't want to redistribute the App every time a new contact is added to the list, so the contacts file must be a in a place that's accessible both by the App and by a PC with a USB connection to the phone.
That being said, what do I need to enter on the file name in order to read if from /storage/emulated/0/Android/data/packageName/files/
?
Best Regards,
Rui
Yes, I did.
From what I understood,the filename must be "/Android/data/packageName/files/filename.extension"
Is this correct?
Best Regards,
Rui
On Android 10+ (to save / read a text file with the File
component) the path is:
/fileName.txt
This path is redirected to the ASD for devices with Android 10+.
and on Android < 10 the path to the ASD (for the File
component) is a relative path:
/Android/data/packageName/files/fileName.txt
Why don't you store the file in a shared directory?
/Downloads
or /Documents
would be the correct place..
Taifun
And how would I reference a shared directory such as /Downloads or /Documents?
As already said
Taifun
So they are interchangeable? I can use any of the 3 formats?
These questions might seem silly to you but I'm only using MIT App Inventor for a week
as @Anke already tried to explain, generally they are the same, however some components require a specific format
please check the documentation for which type of path to use... for the file component just use the relative path
Taifun
Hi, good afternoon.
I've been trying to save the file on /Downloads, but without success.
I've tried:
/Download/test.txt
/storage/emulated/0/Download/testt.txt
file:///storage/emulated/0/Download/text.text
But nothing worked....the file names are always appended to the ASD. For instance, if the file name is
/storage/emulated/0/Download/test.txt
it will try to save on
/storage/emulated/0/Android/data/appname//storage/emulated/0/Download/test.txt
Am I doing something wrong?
Best regards,
Rui