Use new "scope" properties File

Hello,
I am creating an application that needs to read and write many files and directories.
The user must be able to have direct access to these directories to put files there himself.
I am testing the application on two devices, a tablet and a phone.
With this simple block, I don't have the same result.

image

On the tablet, the directory is created but on the phone, I have an error message.

"Cannot create directory at /Storage/emulated/0/Gestion_hand"

Both are under andoid 11 with the same permissions on multimedia files.

Thanks

Set the path to /Download/Gestion_hand
Taifun

2 Likes

After targetSdkVersion=30 you can no longer create your own subdirectories in the root dir of the external storage on Android 11+ devices. (Note: this is also not possible using SAF.)

But you can do it in one of the Shared folders like

  • /Documents
  • /Download
  • /DCIM
  • /Pictures
  • /Music
    ...

See also here:

2 Likes

Hello,
Thank you for your answers, I suspected that the solution was on the shareable folder.
But what I don't understand is why it works on the tablet and not on the phone. Both are under android 11 and with the same permission ???

Show the blocks that will be used to create the folder.
Are you absolutely sure that both devices are running Android 11?

@Anke

Based upon what you have said above.....

Compiled app, Android 13

Attempting to create a sub directory in the shared /Documents folder

This throws the good old 908 WRITE_EXTERNAL_STORAGE error

Any previous folder called MyFolder has been deleted.
DefaultFileScope = App

The blocks work just fine in Companion

:question:

What happens, if you first ask for write permission?
Taifun

App returns the same 908 error (and folder not created)

Added Anke's MFile extension, this does create the directory :slight_smile:
(but now I need to copy files from the ASD to /Documents/MyFolder, this doesn't work with the file component, and no copy blocks in MFile - ah, hang on, need to put some files in the ASD :upside_down_face: - edit, no does not copy )

Which looks like a bug... @ewpatton do you agree?

Taifun

hmmm

Perhaps this helps to explain

There are these little nuggets from Anke spread all over the community, just a case of using the correct search terms. It is getting them in chronological order that matters :slight_smile:

I really don't know how many times I've pointed out this bug (I haven't gotten any feedback from the MIT team on it yet). I will definitely not link there anymore.

WRITE_EXTERNAL_STORAGE must be declared in the Manifest also on Android 11+. There is ONLY one way to do this, namely to set DefaultFileScope = Legacy.

1 Like

That helps to round off what was said earlier in the topic then :smiley:

Tested on Android 13 compiled

Default filescope set to Legacy
Extension DeclareReadWrite (MIT - please add this functionality)

Using native File component, able to:

  • Create directory in /Documents (MyFolder)
  • Copy files from Assets to ASD (I believe this already worked?)
  • Copy files from ASD to /Documents/MyFolder
  • Access and upload files in /Documents/MyFolder from a Webviewer (more on that to come!)
  • Delete files in /Documents/MyFolder

Brilliant!

Thank you @Anke
:smiley: :+1:

(I will get the hang of all this one day, hopefully before it all changes again :upside_down_face: )

Here is the explanation & the Solution:
https://community.appzard.com/t/storage-permissions-read-write-defaultfilescope-appzard-staff/1038/9

https://community.appzard.com/t/storage-permissions-read-write-defaultfilescope-appzard-staff/1038