Android 11 and Storage-File

Unfortunately all my devices have upgraded themselves to Android 11. This new version of Android places serious restrictions on files and directories that can be viewed by third-party apps – like a File Manager.

As one method of debugging I create a log file and put the file in a directory that can be viewed with a file manager. I write various strings, values, with a timestamp to the log file as my app executes. Android 11 does not let me view the /sdcard tree and I can't view the app's internal directory.

The half a dozen file managers I've tried on Android 11 devices let me view "Internal Storage". I don't know if I can write to a file located somewhere within "Internal Storage" with App Inventor.

Can anyone offer suggestions? The things I am debugging are more similar to "does my code execute the expected code and do I receive values from Android in the format I expect" rather than "does my code calculate the expected result".


Save files in Application Specific Directory.

Thanks, but, from the documentation…

Saves text to a file. If the fileName begins with a slash (/) the file is written to the sdcard (for example, writing to /myFile.txt will write the file to /sdcard/myFile.txt). If the fileName does not start with a slash, it will be written in the program’s private data directory where it will not be accessible to other programs on the phone.

In Android 11 the new file protections seem to make the /sdcard directory tree protected and not visible. The app's private data directory is also not visible to third-party applications, such as file managers.

Is there a way to create a file that is publicly read/writable on newer versions of Android?

1 Like


On my Android 11 device it does not allow apps to view the Android/Data directory tree. For many reasons this is an absolute pain.

I dug up one of my old Android 7devices. When I tell App Inventor to store the file in /dbg.txt it shows up in the … emulated/0 directory as expected.

Android 11 is a monster :frowning_face:

It is not a problem to list (all) files in this directory.

1 Like

Android11 również umożliwia zapis do dowolnego folderu, jedynie wymaga specjalnego uprawnienia oraz działania użytkownika przed pierwszym użyciem:

  • Declare the MANAGE_EXTERNAL_STORAGE permission in the manifest.
  • Use the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app: Allow access to manage all files.

To do this, you would need an extension. Unfortunately, if you want to put your app in the google store with this permission, google will probably reject your app. Special apps such as anti-virus programs, file managers, etc. may have this permission.

More here:

Regular apps can write files without any permission in the ASD directory (app specific directory). Unfortunately, it is only suitable for files used only in your app, temporary files, databases, etc. When, for example, your app takes pictures and you want to be able to view these pictures in other programs, and also if you do not want the pictures to be deleted when your deinstall app, it is not a good choice of storage location.

Android 11 also offers the option of saving in other folders, but these are folders predefined for a given file type, for example:

  • Images, including photographs and screenshots, which are stored in the DCIM / and Pictures / directories. The system adds these files to the MediaStore.Images table.
  • Videos, which are stored in the DCIM /, Movies /, and Pictures / directories. The system adds these files to the MediaStore.Video table.
  • Audio files, which are stored in the Alarms /, Audiobooks /, Music /, Notifications /, Podcasts /, and Ringtones / directories, as well as audio playlists that are in the Music / or Movies / directories. The system adds these files to the MediaStore.Audio table.
  • Downloaded files, which are stored in the Download / directory. On devices that run Android 10 (API level 29) and higher, these files are stored in the MediaStore.Downloads table. This table isn't available on Android 9 (API level 28) and lower.

More here:

and here:

Ai2 is not yet api level 30 targeted, so it does not yet include the appropriate tools for saving files for android 11. We have to wait until the end of summer to see what MIT comes up with. If this is not enough for the users, I think there will be appropriate extensions to save files in all ways.

1 Like

I have some doubts about that and, to be honest, I have little (actually no) hope that this will be possible.

1 Like

Great. I will search for third-party file managers that use these two permissions: MANAGE_EXTERNAL_STORAGE

It's very convenient to share files between apps and look at our modify the contents of an app's files using a third-party app.

**** Added a little later ****
Thanks for the pointer.

I found a new file manager app that can view the Android/Data directory. It showed my AI app ASD and the log text file I had saved.

The new file manager app is on Google Play if anyone else is interested:
It is called Explorer from Speed Software and it's free.

1 Like

Yes, there are a lot of those. I already posted a link.

1 Like

Btw, the Explorer app doesn't declare these permissions in the Manifest and its targetSdkVersion is still 29 (Android 10).
It declares android:requestLegacyExternalStorage="true" in the Manifest, which will be ignored when apps must target API 30 (Aug 2021 for new apps and Nov 2021 for updates).

It declares <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> that is no longer available on Android 11 (targetSdkVersion=30).

1 Like

My phone was upgraded to android 11, my apps that read and write on Documents folder run well, If I understand well they will stop to run in Aug 2021 for new apps and Nov 2021 for updates. Is it correct ?

1 Like

Yes that is correct, because writing in the folder /storage/emulated/0/Documents/ will no longer work on devices with Android ≥ 10 when AI2 is targeting Android 11.

1 Like

Will they stop to run even without modification on my part ?

1 Like

No, they will continue to run
Also it has been announced, that we will be able to access shared storage in future, see also


There is currently no component that can save files in the external storage on devices with Android ≥ 10 (outside of the ASD, with the exception of the File component with Legacy mode; however, this is ignored under Android 11). In this respect, @patel must have used an extension for saving files in the external storage on devices with Android ≥ 10.

However, this is no longer possible under Android 11 (targetSdkVersion=30), because WRITE permission no longer exsits under Android 11. Therefore it will stop working on devices with Android ≥ 10 when AI2 targets Android 11 (Aug 2021).

1 Like

Hello Anke. My File1.LegacyMode block stopped working yesterday. Any suggestions ?



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.


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

Will send snapshot in 45 mins.

It is pretty simple. My local file procedure where i write or read or check for presence, must start with File1.LegacyMode True in order for File1 to work. It was recommended by you or Anke a few months back with the warning that it was going to stop working in a few month.

I guess a few months was yesterday. On err i check my blocks and LegacyMode block was floating by itself. It was not connected to a File1 control, so AI2 doesnt recognize it any more.

I deleted LegacyMode block and error warning disappeared but rest of File1 blocks failed, can't read/write or check for presence.

This is apparently an error of omission transitioning into nb187 File Scope handling.
There should probably be some extra code at app load time to transition the old blocks and attributes to the new system.

P.S. some manual conversion guidance from @ewpatton would help here in the meantime.