SAF: App Inventor implementation of Storage Access Framework

Yes, but you asked

and the answer is (again) no.

But you can select / pick e.g. a text file from the root dir of the external storage and read / write from / to it.

3 Likes

Hi
If I don't select a document in open single document list and click the back button all the way to the root level I get this error message.

I am using the Saf_readWrite.aia sample

2 Likes

If you didn't choose a document, then uriString and uri returned will be empty.
image

If I decide not to choose a document and just want to get back to the main screen, How do I close the list without getting this error?

2 Likes

Check if uriString is empty or not before proceeding.

1 Like

Usually empty string and nothing are not the same... this is something which should be fixed in the extension

Taifun

4 Likes

The error is from FileTools extension, so yeah needs to be fixed.

1 Like

Okay thank you.

I put in some blocks to check for urlString empty.
Seems to work...

2 Likes

ChangeLog Version 1.1

New Blocks
image
image

Changes

  • Removed category param from OpenSingleDocument method
  • GotCopyResult and GotMoveResult now return resulting/target document's uri

Bug Fixes

  • Fixed issue in write methods
  • Fixed null pointer exception when SAF picker was cancelled by user
    Reported by @Kevinkun
5 Likes

I'm having a problem.
I use SAF.openDocumentTree and in SAF.gotUri I save the uriString in tinydb so that the next time I can use the uriString from there.
When i put SAF.listFiles in SAF.gotUri I get result from listFiles.
However when I press a button in my app and do 'openFiles' and use the value from tinydb the app stops. well not really stops, but goes to background and nothing happens.

1 Like

Can you post a link to sample apk?

1 Like

I made a basic app with same SAF components/functions and then it works how it should work.
So it's something in my app, I will walk through it again.
Is it possible that file scopes are breaking SAF?

1 Like

Definitely no.

2 Likes

I tried my app on my old phone (Android 7.1), it works there, not on my new phone (Android 11).
When I put the SAF.listFiles in SAF.gotUri on the Android 11 phone it works, but the app crashes when I only save the uriString to tinyDb in SAF.gotUri and have a separate listFiles function.
I could put SAF.listFiles in SAF.gotUri, but that's not nice, then the user must select the folder each time when they get in this screen or press on showFiles button.

1 Like

Can you post an aia that shows the behavior?

1 Like

Did you take the persistable uri permission? :sweat_smile:

1 Like

What does that mean?

1 Like

ah, I see :slight_smile:

What are flags? :frowning:

1 Like

see here

2 Likes

It's working now :slight_smile:
Thanks!!

1 Like