2

enter image description hereIn 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

Raj Shah
  • 480
  • 1
  • 7
  • 21
  • 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

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
  • 6,227
  • 2
  • 6
  • 19
1

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
  • 506
  • 1
  • 6
  • 12
-1

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
  • 581
  • 2
  • 4
  • 11