Error 2102 (file name) could not be opened

Hello! I keep having this problem, on one tablet this error doesn't show but on another one it does. I have both files in downloads and they have the same name.
The app tells me the file is the existing directory but when I try to open it it appears the error 2102 /downloads/filename.txt could not be opened.

I have the file DefaultScope in "Legacy" (before I had another error when opening the file and this fixed it).

Hello Adriana

  1. We need to know the exact Android version of both Tablets.
  2. What is the actual path string assigned to 'NombreDirectorio'.
    ... it may need to be a full path: '/storage/emulated/0/Download/Documents/'

The one that works fine is android 6, the one with the error is android 11.
Nombre directorio is just /Download/

On Android 11+ you can only access non-media files (in one of the Shared folders, like /Download), that are created by the app itself. Otherwise you need SAF.

Read my previous post.

thankyou very much Anke, how can I get SAF in my app inventor?

After a quick search in the community you could have found this

Taifun

Thankyou!
but saf has no "isDirectory" or "Exists" or "GotText"


image

Hello, does anyone knows the equivalent to the functions:"isDirectory" or "Exists"
And the equivalent to the block: "GotText"
Thankyou!

image

I don't really know as the SAF examples are all snippets and assume a familiarity that I for one do not have.

However, this is roughly what you are looking for. My understanding is that you need to make a SAF tree (List) of available files to get the Uri of the one you want to read.

blocks

@vknow360 it would really help everyone if you could create a fully working example, Blocks and AIA (I cannot read most of the Blocks images you have posted on the extension page, the text is too tiny on my screen) that:

  1. Finds a text file
  2. Checks the File size
  3. Reads the File

...without presuming that any preparation required has been performed.

Read a text file (abc.txt) in the Shared folder /Documents:

2 Likes

grafik

1 Like

Btw, this is another bug with the File component:

It should work without READ permission on all Android versions.

See also here:

Anke, if there is more than one text file in the directory, you can't leave the title blank, so therefore it's necessary to list the files in the directory in order to pick the correct one (if it is there). Before you can list the files of a directory, you need to know the directory path.....

I don't quite understand where the connection to my statement is.
The simple questions are:

  • Is there a specific directory and
  • a specific file in that directory or whatever directory?

Whether there are other files in this or that directory is another question.

Anyway, it's a bug in any case, because it should be possible to check this without requesting READ permission.

.... my comments are with reference to your example in post #11

That was just an explanation that these blocks basically (always) work (regardless of SAF). However, these are not required, because you have to open (select) a directory in order to be able to use SAF.
Therefore, these blocks are not required for SAF.

Thankyou very much Anke, can I leave the file in the /Downloads/ folder?
And also can you explain a little this block of code(when saf got uri)? I tried implementing it but it doesn't seem to work, (with the 2 other blocks to read a file) , my mit app gets 'stuck' and it disconnects.
Thankyou!
image

image

Adriana, could you please re-post your Blocks using App Inventor to capture them:

Right-mouse in the Blocks work area and select "Download Blocks as image"
download blocks