There are basically 3 types of storage permissions in the android app settings:
My app requires the highest permission, so I use <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
in manifest.xml
.
Now I want to block the whole app, if the permission is not granted. So I tried using this code to check, if the highest permission is granted, but it always returns false.
if(ActivityCompat.checkSelfPermission(requireActivity(), Manifest.permission.MANAGE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
I also tried using WRITE_EXTERNAL_STORAGE
, but it also returns true at the second option "Allow access to media only".
Conclusion
I am looking for a boolean
function:
Returning true, if "Allow management of all files" is selected
Returning false, if "Allow access to media only" is selected
Returning false, if "Deny" is selected
Thank you.
Environment.isExternalStorageManager().