SAF: App Inventor implementation of Storage Access Framework

As Sunny (the extension developer) has already explained, the possibilities of using this extension are almost unlimited, so it is hardly possible to present all possible scenarios in tutorials/examples.

Therefore, proceed as most users usually do

  • describe your specific goal / problem(s) in detail,
  • show us what you have tried so far (blocks & aia) and
  • where you get stuck.

Then someone (at least from the power users) will surely be able to help you.

See also here:

Note: It would also be helpful (at least that's how I see it) if you open a new topic for it, so that later users can more easily find the solution to your specific problem.

1 Like

dear vknow360, I have read the usage example in the first post. But still dont get it. I can open window to pick a folder, but do not know how to open assets packaged file.

My case is simple, I want to open assets packaged file, then read it with ReadAsByte array and store it at Empty list

You cannot open the assets folder from your device. It is in the internal storage (that is only accessible with a rooted device).

Copy the relevants files from the assets to one of the Shared folders (like /Documents, or a subfolder of it) and open / pick this folder ...

1 Like

It is possible and you can sponsor the feature. :smiley:

1 Like

... to open the assets folder with your SAF extension?
How should this be possible? (I don't think so.)

1 Like


Still can't read file as list/array.
very appreciate for your help :pray:

No, to read file from assets as byte array.

2 Likes

The examples are not complete Sunny - we need them to be 'A to Z', not 'G to P', because SAF is unfamiliar territory. :koala:

1 Like

I can provide examples only if I know the use scenarios.
Please suggest some of them.

1 Like

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.

4 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.