SAF: App Inventor implementation of Storage Access Framework

Vielen Dank!
Did I miss that in the docu?

1 Like

Can I use OpenSingleDocument only the first time, save uristring in tinydb, then read the document using the saved uristring ?

There is no definite answer. It may work or may not.
Please try and let us know.

I tried with these blocks without success

ChangeLog Version 1.2

New Blocks

Changes

  • Minor internal changes to increase reading and writing speed
  • Works more efficiently now

com.sunny.saf.aix (26.8 KB)

7 Likes

hello.. i need help. how to check if a known filename (for example : test.txt) is exist or not in a folder?
my purpose is, if the file is not exist then create a new one. if the file exists, then delete this file and then create a new one with the same name.
i tried CreateDocument function with same filename, but it will create a new file with the same name but with counting number after it, instead of replacing the old one. in post #223 Paul asked about this too, but there was no answer.

grafik

i see.. so i have to use File component too besides SAF. Let me try it, thank you Anke

i have suceeded checking the file is exist or not using File component. Now i will delete the file if it is exist. Does delete function from File component work on android 11+? or should i use delete function from SAF component?

It'll not work unless file is created by your app. So you should use SAF to delete the file instead.

1 Like

i see... but how can i delete the file using SAF? because i need to get documentUri in order to delete that file. AFAIK i can only get documentUri by opening it first. or does your component have function that create documentUri if i input treeUri + filename?

It is the recommended way to obtain document uri.
However you can try to build document uri manually with BuildDocumentUriUsingTree block.

i see
in BuildDocumentUriUsingTree block, there are 2 input parameters, the treeUri (i can get this parameter by using OpenDocumentTree block) and documentId. Is documentId the same as filename?

That depends upon whether file is direct child or grandchild of tree.
I would like to know directory structure before making any comment on it.

the tree i am creating is root/mydirectory/filename.txt

Show your blocks.

Sunny, what is the mime type for the xml files kml and gpx?

These are text files used for geolocation.

I have tried all of these 'standard' mimes:

mimetype
but the file is only recognized if I convert the suffix of the actual file from kml or gpx to txt.

The question is can kml and/or gpx files be selected using this Block?

Thanks. --Steve

Try application/vnd.google-earth.kml+xml and application/gpx+xml.

From Keyhole Markup Language - Wikipedia and gpx mime type? - Phoca Forum.

thanks for the idea. I saw it but now I tried it and it is not recognized. I expect kml is just not an option as a text file in SAF.

1 Like