Reading file data from a browsed local file

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)

Regarding the SDK30, If I do end up fixing what i have now and getting it to work, it won't matter in the future, right?
Thank you

display the response in a label


and check using a file manager, if the file really is in the ASD

sorry, but SDK30 will bring changes to everyone... including you...

Taifun

Here's the response:

Blocks:

ok, the response is not very helpful...
what about

Taifun

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!

tested (my blocks) using companion on Android 11, doesn't work for me..error 2101 / not found - not reading file from Download folder

I tried to search for a way to do this but I can't seem to get it to work..
I tried to use your "Exists" function from your extension to check whether the file exists, it shows that it does exist in the ASD (unless i don't understand how it works..)
Here are all the blocks:

Here's the block from your extension that I added:

And here's there result:

What can I do at this point? does the file really exist in the ASD and the whole problem is the "ReadFrom" function? or is something else?
If the "ReadFrom" function is the problem, how can I edit it/fix it, or maybe use something else that will actually read the file?

Thank you..

is there a space after the /?
what happens, if you use a text block together with the text /TestRoute.txt to read the file?
Taifun

There isn't a space after any of the /.
By using a text block, do you mean like this?

Nothing different happens.. though, if i do change the /TestRoute.txt to anything, say /TestRote.txt, your "Exists" function still returns true, as if the file exists. but a file named /TestRote.txt clearly doesn't exist.
Edit: I did a wrong test. the "Exists" function works, and it only returns true when checking for the TestRoute.txt file, which was copied to the ASD. so the file is in the ASD it seems, but the "ReadFrom" function still isn't working for some reason...

This will try to read file from /storage/emulated/0/TestRoute.txt which does not exist.

no, because starting from Android 10 the file component reads from the ASD (at least currently, this might change after SDK30)

this works for me (Samsung Galaxy A51 running Android 11)

Taifun

floof.aia (34.4 KB)

1 Like

Good morning, I used your blocks on my Galaxy s20 ultra (android 11) and it worked, but it still displayed an error (but it did read the file, and it displayed the text on a label), this is on android 11.
I think this error comes from the "AfterActivity" event block:

And after clicking Read File:


And as you can see, it doesn't display the file's new path..

Here are the blocks:

Edit: If I try it on another file other than TestRoute.txt, it doesn't work for some reason.. it also doesn't work on a .csv file.

However, when trying it on my Galaxy S8 (I just found out it's running Android 9): it gives the following error:


I know it should be dealt with differently on android <10, though I don't know how to do that. Is it possible to make it work on all versions? like, to add an If statement block to check which version of android, and then do the corresponding method?

Thank you so much for your time and help, it is much appreciated!

ok, you have a working solution to read the file in the ASD then

the activity starter can't pick a file from the assets of the app... you already had a working solution to pick the file previously... why don't you just combine the 2 working solutions?

this is the same error, tha activity starter can't pick files from the assets

Taifun

As I've stated up there, it's not working for other files, other than the TestRoute.txt.
What you built in your aia works because you manually uploaded the TestRoute.txt file into the media here: image

This isn't what i'm trying to do. what my app needs to do, is allow the user to upload a file (any random .txt/.csv file) from their phone, to the app, and then see the contents on the file. the file cannot be uploaded as a media beforehand... instead, the app should allow the user to access his phone's file, and pick a file from there, and then display the contents in a label.

I tried to use your blocks to do this, but as I said up there, it didn't work for files other than TestRoute.txt, and it still gave an error for some reason.. so as of now, no, I don't have a solution that works :frowning: ..

Pick_file_test.aia (70.3 KB)
Here's my aia if you'd like to have a look at it and test it (if you have time of course..) it's only to specifically test this issue, which is to choose a file from the phone's storage and then display the file's contents in a label.

Uploading the file via the media just beats the whole purpose.. the user has no access to the media nor can they upload the file to the app through there.. it has to be selected (browsed and uploaded) through the activity starter into the app.

I hope this makes it clear, I'm sorry if I misunderstood something..

Again, Thank you so much for help, it is much appreciated!!

your task does have 3 steps

  1. pick a file
  2. copy it to ASD
  3. read it from there

1 and 2 was working, see #27 here Reading file data from a browsed local file - #27 by Floof_h

you had problems with 3) and therefore I wrote a small example app for you, which reads a text file from the ASD.... and to have the file in the ASD as test I copied the file from the assets to the ASD...

you now only have to take your previously working solution for 1) and 2) and add the solution from 3)

sorry, I do not have time now...

Taifun

I did combine 1,2 and 3 all together, and i've posted the result of that in the previous post.. I still get an error, and it's not working for files other than TestRoute.txt.. here are the blocks for that:

If I try this on any other file, it would not work..
Here's an example.. I've done exactly the same thing. clicking on Browse, but now, I choose another file instead of TestRoute.txt. and as you can see, it cannot read it for some reason..

And after I click on Read File :
image

What am I missing? it should be working, right?

sorry, i do not have time now...

It's alright :slight_smile:
Thank you..

The error message is telling you, that you can't pick a file from the assets...

Taifun

Any idea on how to fix it? what am I doing wrong? I can't figure it out..