I have struggled trying to figure out how the storage system work on Android. Now I am stuck at requesting permission for WRITE_EXTERNAL_STORAGE, and I am using Android 7.1.1. Here is my code:
int check = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (check == PackageManager.PERMISSION_GRANTED) {
//Do something
} else {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1024);
}
UPDATE: So the code does work, it didn't work before because I had a typo in AndroidManifest.xml, thank you for all of your help!
Add permission to your manifest file ...
Try this,
get Permissions Result
check permissions for marshmallow
Manifest
If you wan't to check multiple permissions at time then add permission into PERMISSIONS array like: