SAF: App Inventor implementation of Storage Access Framework

I need to pick file or folder for opening, after picking I get automatically write/read permissions, why there are permission blocks ? When I need to use them ?

grafik

Is there a reason why this is not available in your latest extension version? @vknow360

Sorry, I forgot to add that method.
v1.2beta :
com.sunny.saf.aix (33.4 KB)

1 Like

:+1:

Firstly, why is the file in the Download folder? Does it have to be downloaded from the cloud? If so, you can download it directly to the App's ASD folder:

However, Download is an Android shared folder, you do not need SAF to access it.

After getting the URI, copy the document to the Shared folder /Documents or the ASD and then access and upload this file from there with the real (absolute or full) path.

See also here:

Goodday,Have created a read file block successfully which read the file as bytearray.

I can read the result into a label block

How to read it like array in for loop with indexing

Thanking you

Sorry, please elaborate.

Good day Sir,

Using SAF I read a binary file which contains numeric value as byte array

Using after read block I read the result into label and display the values, I can see the read values

Now i want to read directly from result (byte array) to a textbox one byte at a time in a while or for loop, how can I achieve it.

I tried to read the byte array to list but it says bad argument.

Hope I had explained my problem. I am replying through my phone, no access to my PC.

Thanking You for reply

Hi @vknow360 & All,
Writing my app to read text LOG.adi file (https://adif.org).
Now : how to convince Android to let SAF extenstion choose it for open using OpenSingleDocument ?
If I set AdiType to "text/*" and rename file to LOG.txt Android allows me to choose this file (it works fine) and other files (e.g. log.adi) are grayed-out and not available for selection.

What shall I set Aditype to to get Android allow me to chose only files with .adi extension ?

17 posts were split to a new topic: Companion issues if using extensions (on Android 13)

Dear Sunny @vknow360,
I use yr extension and it is great. Now I need to write my extension to process bytes read returned as result from GotReadResult after call to ReadBytesAsByteArray - the question is : what type is the result ?
Is it List result ? basically my intetion was to parse char[] result but I do not know where my error is ?
regards Kuba

SAF is open source, Why not check by yourself?

It returns byte[] as object.

1 Like

Dear @Kevinkun ,
could you show me how to declare Simplefunction (method) for my TEST extension that can directly take this result as byte[] . I can not "unwrap" that array from object :frowning:
Regards, Kuba
P.S. Yes, I've been looking into your code.

SAF How do you Create a Folder?

I would like to create a folder in Documents using SAF. I would like to do this to keep my different application's .csv files in organized locations. On the page dedicated to SAF " SAF: App Inventor implementation of Storage Access Framework"

@Narender_Kumar Narender_Kumar posted this statement:

"If anyone want to create a
empty folder after selecting the in "open Document Tree" by using "create document" .
then mimetype is following"
....
vnd.android.document/directory

There must be a little more to it. I have no problem using SAF now to save, copy, delete documents. But I still cannot create a folder.
Here is what I have tried.

The directory is the Documents folder.

But no clue how to create a directory.
Here is what I have tried.


I am not really sure what else to try, but this does not create a folder for me! Any ideas?

Thanks,
Jon

You can create dir in the document tree this way:

But if you want to create a dir which is not a direct child of document tree, then you will have to use BuildChildDocumentsUriUsingTree instead of BuildDocumentUriUsingTree.

Now Test1 will be created in Test dir.
Here Test is direct child of root Tree while Test1 is grandchild.

HOW DO MODIFY AND SAVE IN AI2 A BYTE ARRAY RECIEVED FROM Saf.ReadAsByteArray?

I'm able to read and than to write a content of a binary file using AsByteArray methods of SAF but maybe somebody knows in which way i can modify in AI2 a byte array received from SAF.ReadAsByteArray?
Any modification is converting this byte array in string and I'm receiving an error "java.lang string cannot be cast to byte[]" when i'm using SAF.WriteAsByteArray to save it (see an example below where i''m only substituting [ with the same [ - but if i pass the result of READ to WRITE without modification- everything is working).


There is no need to segment the result.
And, if you want to write file in asd then use CopyDocumentToASD block. You'll not have to worry about manual read and write.