Error 2102 (file name) could not be opened

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


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


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


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.


@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:



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.


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

thankyou anke, i made those modifications and it could now be opened but I have another problem now, the program lines are not being displayed.
Before I had it like this, basically it says "Reading program OK" and then the lines in the program are printed.

Now it tells me that it was read with "Reading program OK" but instead of the lines I get:
No content privided: Programa_001.Txt

your error message is: no content provider
I would try this


Thankyou very much Taifun! That worked :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.