How to access permission allow management of all file in android studio
11,192
Solution 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
Solution 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
Related videos on Youtube
Author by
Raj Shah
Updated on June 04, 2022Comments
-
Raj Shah almost 2 years
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
-
Mori about 3 yearsPlease See this way in this link , It can be useful. stackoverflow.com/a/67140033/12272687
-
Mori about 3 yearsPlease See this way in this link , It can be useful. stackoverflow.com/a/67140033/12272687
-
-
Raj Shah over 3 yearsI want Access this path /storage/emulated/0/whatsapp/media/.statuses but in android 10 & 11 is not working
-
Viatcheslav Ehrmann over 3 yearsIts not working because google forbid this.