Those are just to help me debug what's going on. I only use them to display them in a label afterwards (picture included below).
Here's what I'm trying to do:
The user browses a file from the file manager. here are the blocks to do this:
Now, I'd like to get the data that's in the selected file (the file that the user selected when browsing), Let's say the file is in .txt format, or .csv, I'd want to be able to read the contents in the file, in order to store them in strings that I will use later on..
I'm stuck on this part (2), I can't view the file's content, the "ReadFrom" function is not working for some reason.. I've tried many extensions and sadly I can't seem to get it to work..
what about providing an example filepath and filename as previously suggested?
we then can take a look, if you are reading the file correctly from there
also which Android version are you using for your tests?
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.
I'm using Android 11, on a Galaxy S20 Ultra (and on a Galaxy s8).
Here are a few examples:
When I use only this block,
this is the ResultUri that I get:
As you can see, the file name is numbers (the actual file name is "TestRoute.txt", but it could be any other random name, depending on the user of the application. so, there isn't a specific file name, I need to extract the name in order to call the "ReadFrom" function)
If I use your extension to get the file name from the Uri, I get this Error:
This block works. The weird thing is that it's working for literally any other file that I choose, other than a .txt file..
Here are a few examples:
This "unknown-3.png" image is sitting in the exact same folder as the "TestRoute.txt" file that i'm trying to view.
You may need to try this, which works for me on Android 10 (companion). The File component could be looking at the ASD..., so you may have to copy the picked file there (ASD) first in order to be able to read it.
you are using an Android 11 device
currently the file component only can read from the ASD (and not from a random directory) starting from Android 10
therefore follow this advice
I have tried to copy the file to the ASD, but even then, the "ReadFrom" function doesn't work..
I started a fresh project with just these blocks and to test it, I still get the error that the file was not found.
I checked if the file was copied successfully, also, I'm displaying the new file path on another label
Here are the blocks:
I don't quite understand what the SDK30 is and what it will do.. is there anything I can do to get it to work in my current situation or do I have to wait for the new release?
It does show that the copying was done successfully. (I removed the "ReadFrom" function so that it won't override the notification from the FileTools.FileCopied event)
My apologies I didn't notice that line.. sorry!
How do i check it using a file manager? can it be done with the TinyDB? and if so, can you show how to do it if possible?
Thank you for your time and help!