Read file from phone memory

Hi,
I have save a project as copy and did some modification on print section. It has file read block which I didn't modify. when I simulate the app in AI Companion it worked fine (I mean the file read component). but when I install it phone file not reading.

Please note that the unmodified .apk still working properly.

Thanks


Samitha

1 Like

Try reading file from the file's location in your phone's memory

Thanks for your reply.
The file is located on root directory of phone memory

Thanks
Samitha

2 Likes

So is it your answer?

1 Like

Try copying over the file to another directory (such as Download) and see if it works.

1 Like

Where does the file (Log.txt) come from?
If it wasn't created by the app itself, you won't be able to read it that way under Android 11+ (you'll need SAF for that). And on Android 11+ you can no longer save non-media files in the root dir of the external storage.

See also here and here.

1 Like

Hi Anke,
Thanks for your reply.
The log.txt file was created by myself & paste it to root directory of internal memory. I used com.sunny.EFile extension for read & append to file. Before I do some modification in other blocks it was worked perfectly. And still working my previous built .apk on android 11. I guess this thing happened after new released of nb187d

Please refer the attached screenshots

Thanks
Samitha

1 Like

As I already said you can no longer list / save non-media files from / in the root dir of any device with Android 11+.
To read those files you need to use SAF.

2 Likes

Anke, come funziona leggere file con android 11 utilizzando SAF? Puoi farmi degli esempi?
Saluti
Nicola

1 Like
1 Like

Anke,
dove posso scaricare l'estensione SAF?

Anke

Could you please send me AIA file or block picture?

Anke, mentre stavo scrivendo i tuoi blocchi, ho scoperto che un blocco è rinchiuso.
Ti allego l'immagine

That loop adds document's name to the list since filesList returns content URI.
Search for GetName method in the extension blocks.

E questo è un'altro blocco..

What did you mean?

Could you please show me an example how to read & write a text file? I'm confuse how use SAF Read from file block URI

Did you check the extension topic? Plenty of examples are present there.

2 Likes