How to access permission allow management of all file in android studio
Asked Answered
F

3

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

Fluvial answered 5/2, 2021 at 17:11 Comment(2)
Please See this way in this link , It can be useful. https://mcmap.net/q/89292/-android-11-scoped-storage-permissionsSupersaturate
Please See this way in this link , It can be useful. https://mcmap.net/q/89292/-android-11-scoped-storage-permissionsSupersaturate
E
15

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

Enwomb answered 20/10, 2021 at 11:30 Comment(0)
L
2

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

Lamp answered 5/2, 2021 at 17:30 Comment(0)
S
-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

Sousaphone answered 5/2, 2021 at 17:15 Comment(3)
I want Access this path /storage/emulated/0/whatsapp/media/.statuses but in android 10 & 11 is not workingFluvial
Its not working because google forbid this.Sousaphone
With Storage Access Framework user can choose the folder manually and this way it should work. That's my understanding. Haven't tried SAF out yet, however.Brandi

© 2022 - 2024 — McMap. All rights reserved.