public static boolean checkStorageAccessPermissions(Context context)
    {   //Only for Android M and above.
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            String permission = "android.permission.READ_EXTERNAL_STORAGE";
            int res = context.checkCallingOrSelfPermission(permission);
            return (res == PackageManager.PERMISSION_GRANTED);
        }
        else
        {   //Pre Marshmallow can rely on Manifest defined permissions.
            return true;
        }
    }
public static boolean checkStorageAccessPermissions ( Context context ) { if ( android . os . Build . VERSION . SDK_INT >= android . os . Build . VERSION_CODES . M ) { String permission = "android.permission.READ_EXTERNAL_STORAGE" ; int res = context . checkCallingOrSelfPermission ( permission ) ; return ( res == PackageManager . PERMISSION_GRANTED ) ; } else { return true ; } }
Post Lollipop Devices require permissions on Runtime (Risky Ones), even though it has been
specified in the uses-permission tag of manifest. checkStorageAccessPermissions
method checks whether the READ EXTERNAL STORAGE permission has been granted to
the Application.
@return a boolean value notifying whether the permission is granted or not.