SAF: App Inventor implementation of Storage Access Framework

You cannot select

  • the root dir of the external storage and
  • also not /Download

using SAF.

1 Like

You will have to pick the document at least once to get access to it. After getting uri you can read from file anytime.

1 Like

See also post #31

...... maybe you can't, but I have on Android 10.

On Android < 11 SAF is not needed, because you can access all files (media & non-media) with storage permissions (in the external storage, outside the ASD), since AI2 decided to declare requestLegacyExternalStorage=true in the Manifest.

See also here:

Well, SAF came into being @ Android 4.4, but the purpose of my post was to present a fully working example App, presented in a way that people can actually understand.

Yes, so what ...?

I'm not so sure if people actually understand it. Especially since it is / remains unclear why a text file should be created using SAF if it works without any problems with the File component (or without storage permissions on Android 11+ with my MFile extension), also on Android 11+ (at least for the Shared folders).

1 Like

I'm not sure you understand Anke :koala:

@ChrisWard As Sunny rightly said, explain a specific use case.

As soon as we know this, we can make concrete suggestions as to how this can be implemented with or without SAF.

1 Like

Ther'is a way to avoid many folders selections to find the desired file ?

How do you / the user know what the desired file is (and where that file is located)?

My fle path is /storage/emulated/0/MyFolder/Appunti.txt, I'm sure it exists, I would pick on it without many folders selections

Ok, since you seem to know what the file is called and where it is located, where is the problem then?

Try setting initialDir to content://

When you choose a dir with SAF Picker you will find tree in place of document.

1 Like

I tried with this block, it runs well, but how can I select the file ?

By clicking on it. (How else?) :wink:

How can I get the selected file uristring ? With OpenDocumentTree block I get the uristring of selected folder, not the uristring of selected file-

I know the folder, I know the filename , is it possible to open it with only one pick ?