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).
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.
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:
Finds a text file
Checks the File size
Reads the File
...without presuming that any preparation required has been performed.
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.....
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!