How To Get All Files Access Permission In Android11


Android11 Introduced A New Storage Access Permission Called All Files Access. This Permission Will Give Us Access To Any Content Inside The USB Storage Of The Android Device Except The Android/obb & Android/data Directory. In This Tutorial We Will Learn How To Add This Permission To Our Project.

Step1. Create Or Open An Existing Android Project.

Step2. Open Your Project Android Manifest File & Add MANAGE_EXTERNAL_STORAGE Permission.

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

Step3. If You Want To Check If The User Allowed The Permission Or Not At Runtime You Can Use Environment isExternalStorageManager Boolean Method.

if(Environment.isExternalStorageManager()){
  //Permission Allowed
} else {
  //Permission Not Allowed
}

Step4. Also If You Want To Redirect The User To The Permission Authorization Page You Can Use  android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION Intent Flag.

Intent intent = new Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION", Uri.parse("package:" + getApplicationContext().getPackageName()));

startActivity(intent);

Step5. Finally You Have Added All Files Access Permission To Your Project.


              Thank You For Reading

Comments

Post a Comment

Popular posts from this blog

How To Create First NodeJS Application In Android

How To Create PDF Reader App In Android

Color Picker In Sketchware Pro