SAF: App Inventor implementation of Storage Access Framework

Don't get me wrong, your work on this extension is a masterpiece, small wonder that Evan wants you to integrate it into App Inventor.

I can suggest the examples you have already made. The issues:

  1. Incomplete. SAF is baffling when you first see it, so examples should actually work stand-alone.
  2. Old version Blocks used.
  3. No introduction to the example describing what it's goal is.
  4. Unattached Blocks
  5. Anonymous inputs
  6. Unreadable images

If you make more comprehensive examples, there wouldn't be so many posts from people asking what they have done wrong - including posts from fellow Power Users.

1 Like

Create a text file in an external folder of your choice from the Root Directory and write to it.

SAF_CreateTextFile.aia (31.8 KB)
Note: Add the SAF extension first! Can be tested on your device via Companion or as an APK.

3 Likes

I tested your aia with companion, it runs well, I created file, how can I read it without selecting folder?

As far as I know, you have to access the files by selecting the folder, this is how Google have designed the system to try to block hacking.

This is all you need to create a new text file in e.g. the folder /Documents:

2 Likes

Actually if I leave the directory path blank, it defaults to the Downloads folder on my phone and I can't navigate from there, so starting specifically at the Root Folder (or any specific folder) is more reliable.

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?