Error 908: The permission WRITE_EXTERNAL_STORAGE has been denied - to write a text file

I am running an AI app on an Android 11 phone. The app writes to a file on the phone and has been working for 2 or 3 years. But when I made a small change last week and re-installed it on my phone I got the above error.

I have seen other posts about asking for permissions but have never had to do this. I believe this is the first time I have re-installed the app since my phone was upgraded to Android 11.

I notice in my phone "Settings>Privacy>Permissions Manager>Files and media" it shows "Allow access to media only". In another AI app where I write to a file on my phone it shows "Allow management of all files" - I have not re-installed this app since my phone was upgraded to Android 11.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Hello Graham

Sounds like you are writing to a file within a folder created by your App. If that folder is not within an Android Shared Folder, it breaches Android 11's security measures. If the file is not shared by other Apps, it can be saved in the ASD (App Specific Directory).

I have found that my problem is not with file access on my phone but with the CloudDB component. I have created a test app using CloudDB which only does StoreValue, GetTagList.

I am using the default MIT server.

When I build and open the app I get the “WRITE_EXTERNAL_STORAGE” message.

If I disable the CloudDB.StoreValue block I don’t get the error message.

There is no File component defined in the app.

My problem seems to be exactly the same as another post “Android 11 does not work with CloudDB”

In Screen1.properties, set Scope to Legacy. This has worked for others...

1 Like

Yes, all components that write anything needlessly request Write permission in android 11.

Setting Scope to Legacy has worked in my test app. I'll try it in the proper app now.

And again:
No, WRITE cannot be requested on Android 11. There is only an error message that is generated incorrectly by AI2 (apparently with all components that can save) if WRITE is not declared in the Manifest. However, if the storage permission is granted (and that can only be READ, because on Android 11 WRITE works just like READ), it works.
This is the same bug as e.g. with the Canvas component.

See also here:

As he called, so he called, but we know what's going on. In all writers, there is a permission related bug.

When the READ permission is requested, the components incorrecly query whether WRITE permission is declared in the Manifest.

And why, for example, canvas will request read permission, if, for example, I want to use canvas only for writing? I don't want to read anything, I just want to write. Then, canvas shouldn't be asking us any permissions for android 11?

For me, all this automatic entitlement demand is one big misunderstanding. Even after adding a regular ListView component, it causes my app to be granted read permissions in the settings.

As I said, if WRITE permission is declared in the Manifest it work the same way as READ permission.
Of course, Canvas must be able to request READ permission on Android 11.
Note: READ permission works the same way on all Android versions.

Why "must"? I want to use the canvas component for drawing only. For example, I want to make a joystick, why the canvas would then require any permissions? I do not want my app to have any permissions that it does not need, because the user might be suspicious of such an app.

Success. Setting Screen1.properties.DefaultFileScope = Legacy stopped the error message and I'm now able to read the file on my phone.

1 Like

to set a Background image from external storage for example.

Yes, I know. But we don't always use these functions when we only use canvas to draw objects. This is the downside of all automation. Evan wrote in one post that he wants to achieve that apps only ask for the necessary permissions, but I don't think automation can do that.

Of course, permissions should only be requested if they are actually required.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.