Search code examples
androidandroid-storageandroid-11

How to obtain Request All files access on Android 11


Im investigating the File access changes associated with Android 11

I've configured an AVD fro Android R and created a Test Application that has the following Manifest contents

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.my.application">

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />

I then create this Intent and start Activity expecting to see the Allow access to manage all files. in System Settings

    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
    val uri = Uri.fromParts("package", packageName, null)
    intent.data = uri
    startActivity(intent)

However the user is presented with the App Info screen for my test application.

If I search in settings I can find the Apps & Notifications -> Special App Access -> All files access -> My test app is listed

Is this the process users have to follow to grant this permission?

Why doesnt using the Intent I constructed take the User directly to the All Files Access page?


Solution

  • Implementing an intent for

      Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION 
    

    will give your app read/write access for all files even on removable micro sd card.