SAF: App Inventor implementation of Storage Access Framework


The app stops

Let me tell you the workflow once more.

  1. you open SAF picker
  2. user choose a document or tree
  3. you get the uri
  4. you take persistable uri permission
  5. you do the whatever you wanted

:slightly_smiling_face:

3 Likes

[quote="vknow360, post:144, topic:41603"]
When i'm using SAF picker I can read and save my doc.
But I don't want use the picker, I know the uristring, I want read the file directly.
I don't understand if you don't want help me or if you can not help me.

Ok, so you tested with the APK, true?

This is not possible, you must obtain access using ACTION_OPEN_DOCUMENT.
So you cannot read / write from / to it directly.

1 Like

For me it seems to work also without permissions (with Companion & APK):

3 Likes

In short, you can't use SAF without using one of these blocks:

grafik

To create a new doc, the first block and the CreateDocument (plus TakePersistableUriPermission) block must be used. The second block must be used to read or write to an existing doc (and it seems this is also possible without PersistableUriPermission).

3 Likes

I agree with you, maybe it's not possible now without OpenDocument, but I think vknow360 could implement this feature

1 Like

Nope, not possible. You must use one of those picker blocks, at least once.
You can't reach to the roof without climbing stairs. :wink:

8 Likes

can you explain why ? with opendocument you can get permissions, you know how.

1 Like

PersistableUriPermissions apply to directories, not documents. When a doc has been opened (picked), it seems you have unrestricted access to it.

1 Like

I updated my post, #138.

1 Like

it runs well

1 Like

If to read my text file I have to open the folder and pick the file I might as well use a file browser without making a dedicate app

1 Like

If you want to do it without SAF, the text file must either be in one of the shared folders (/Download or /Documents) or in the ASD.

1 Like

3 posts were split to a new topic: How can I read/write my text file in /Documents?

Is there any way to use the main folder?
In the companion, it was fine but not in the exported APK.

1 Like

No.

No, this also doesn't work with Companion on Android 11+ devices.

3 Likes

It did work for me in the companion, I was able to choose a file and use the URI.

1 Like

You can choose a file from root folder but you can't choose root folder itself.

3 Likes

I don't have enough idea about it...

1 Like