7

enter image description here

In Android 10 & 11 SDK 30 How to access all files in android devices and also give permission of Allow management of all files

I have try requestLegacyExternalStorage, defaultToDeviceProtectedStorage, reserveLegacyExternalStorage and MANAGE_EXTERNAL_STORAGE permission but not working

enter image description here

Boken
  • 4,825
  • 10
  • 32
  • 42
Raj Shah
  • 668
  • 1
  • 9
  • 23
  • Please See this way in this link , It can be useful. https://stackoverflow.com/a/67140033/12272687 – Mori Apr 17 '21 at 15:55
  • **Please See** this way in this link , It can be useful. https://stackoverflow.com/a/67140033/12272687 – Mori Apr 17 '21 at 15:55

3 Answers3

12

You can use the below code. It works for me.

                        if (SDK_INT >= Build.VERSION_CODES.R) {
                            if (Environment.isExternalStorageManager()) {
                                startActivity(new Intent(this, MainActivity.class));
                            } else { //request for the permission
                                Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
                                Uri uri = Uri.fromParts("package", getPackageName(), null);
                                intent.setData(uri);
                                startActivity(intent);
                            }
                        } else {
                            //below android 11=======
                            startActivity(new Intent(this, MainActivity.class));
                            ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
                        }

And add line android:requestLegacyExternalStorage="true" in menifest file

sushant singh
  • 696
  • 1
  • 8
  • 18
1

MANAGE_EXTERNAL_STORAGE

That is only for Android 11 API 30.

You have to start an intent for

Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION

To let the user enable all files access.

For Android 10 API 29 devices

 requestLegacyExternalStorage="true"

will do.

You can read more here: Accessing external storage in Android API 29

blackapps
  • 8,011
  • 2
  • 11
  • 25
-2

You are not allowed to. Nobody is. No, you can not circumvent this restriction.

You can only access, edit and delete the apps own data. For more read here. https://developer.android.com/about/versions/11/privacy/storage

Viatcheslav Ehrmann
  • 716
  • 2
  • 5
  • 11