Android 11 scoped storage/SAF support

Hello, I'm the developer of M64Plus FZ. I have been getting a good amount of bug reports about my app not working correctly in Android 11 with Dig. From investigating the issue, it seems that Dig is providing the app with a file path. When my app tries to load this file in Android, it gets a "permission denied" error.

This is happening because I'm currently targeting my app against the Android API level 30, if an app targets that API level, it can no longer use file paths provided externally. Instead, the only "path" that works when provided externally, are URIs gathered through the storage access framework (SAF), as long as my app has been provided access to the same file at some point.

Unfortunately, the only way to fix this is for Dig to use the SAF file browser to find files. Files will then be in the form of URIs that M64Plus FZ can handle in Android 11.

This is going to be something that is going to be required soon to publish updates in the play store, so it seems like the only reasonable path forward for now.

This is not an issue in Android 10 or earlier because I'm using the requestLegacyExternalStorage flag in my application manifest, so Android still lets me handle the old path style.


  • Hello!

    Thank you so much for writing this post and explaining what's going on!!

    Can I bring up one issue I see with this. There are many users of DIG (and other frontends) that already have large libraries of games, and these games are all saved in the frontends with file paths and not the URIs gathered from the SAF browser.

    Because of this, upgrading to Android 11 will break all of these saved games in these large libraries. I don't really see a feasible migration path to convert the thousands of file paths of games located in different directories (and internal and external storage) to URIs obtained from the SAF browser.

    I do know that there is another solution for apps targeting Android 11 and above (12 for now), and that would be to use the "MANAGE_EXTERNAL_STORAGE" permission.

    Have you considered using this?

  • edited November 2021

    Hello, I just saw that you responded. Here is the answer I gave to the author of the reset frontend:

    There is a way to gracefully migrate from legacy storage to SAF for users that have a bunch of legacy folders and paths stored. Android 11/12 supports this flag in the app manifest:

    When a user updates from Android 10 to Android 11, the requestLegacyExternalStorage flag will work for any apps that were already installed. If a user installs an app that requests requestLegacyExternalStorage in Android 11 that was not previously installed, that flag will not work. What I'm not sure about is if a user installs an app built targeting API 29 that also requests requestLegacyExternalStorage and then the app later updates to API level 30, if the requestLegacyExternalStorage will continue to work. I have the feeling that it should.

    When that flag is available, you can still read the old paths, but when adding new paths, you can store them as URIs as well. You will be able to read from paths or URIs at the same time.

    As for the "MANAGE_EXTERNAL_STORAGE" permission. Google play is extremely picky as to which apps it allows to have that permission. For your use case, it well likely end up being denied. I wish I could had used that permission, since it would had made my life so much easier. The transition to SAF took me a couple of months to implement.

  • edited December 2021

    Wow thanks for posting . So dig launches a older version of your emu on android 11.

    2.0.38 if I remeber right . I assume this is cause changes you spoke of . DIG hopefully will update to accommodate many android 12 and different emu changes .

  • I have beta and it can't scan Android/data folder for Android apps. Os 11 has one option to scan selection for folder while my os 10 has 3 and can do whole device.

    In app permissions/privacy shows it only has access to media files and not all files like some others have.

  • Need MANAGE_EXTERNAL_STORAGE, even though you have read and write external storage

  • Oh and android 11, iin options nstalling themes and changing theme folder don't prompt the browse/selection

  • 1.40.4 theme install works and android apps show, but rom folders can't be added and media folder can't be changed. Getting there!


Sign In or Register to comment.