SAF: App Inventor implementation of Storage Access Framework

I can think of a different way and that is to return byte array as list which you can modify. And when you will pass that modified list in WriteAsByteArray function, the list will be parsed into byte array.

It's even better because in reality i was immediately converting the string received from ReadAsByteArray to the list

Hello @Anke , have a nice day ahead!

I just want to ask where did you get this block that I encircled in the image:

I am trying to read a csv file from my app installed in android version 12. Hoping for your kind response and thank you in advance.

Upload an image to assets and then

1 Like

Thank you @vknow360 , I already found it :pray:

How can I set initialDir ? I tried with fullpath, relativepath, absolutepath without success.

Thanks for the suggestion.
It is now possible to correctly set initialDir.
image

Please download the aix from here:
https://github.com/vknow360/SAF/tree/beta/aix

1 Like

thanks, it runs well

Thenks a lot !!!!
This was the link I was searching for.

Does ListFile not work without OpenDocumentTree before?
I tried the following:
grafik
This works and delivers "content://com.android.externalstorage.documents/tree/primary%3A/Documents" in Label1.
I then tried to simplify it like that:
grafik
the AI Companion closes immediately without running GotUri.
What am I doing wrong?

Yeah right.

You must start with .OpenDocumentTree or .OpenSingleDocument to use SAF.

Vielen Dank!
Did I miss that in the docu?

1 Like

Can I use OpenSingleDocument only the first time, save uristring in tinydb, then read the document using the saved uristring ?

There is no definite answer. It may work or may not.
Please try and let us know.

I tried with these blocks without success

ChangeLog Version 1.2

New Blocks

Changes

  • Minor internal changes to increase reading and writing speed
  • Works more efficiently now

com.sunny.saf.aix (26.8 KB)

7 Likes

hello.. i need help. how to check if a known filename (for example : test.txt) is exist or not in a folder?
my purpose is, if the file is not exist then create a new one. if the file exists, then delete this file and then create a new one with the same name.
i tried CreateDocument function with same filename, but it will create a new file with the same name but with counting number after it, instead of replacing the old one. in post #223 Paul asked about this too, but there was no answer.

grafik

i see.. so i have to use File component too besides SAF. Let me try it, thank you Anke