public static void verifyStoragePermissions(Activity activity) {
        // Check if we have write permission
        int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);

        if (permission != PackageManager.PERMISSION_GRANTED) {
            // We don't have permission so prompt the user
            ActivityCompat.requestPermissions(
                    activity,
                    PERMISSIONS_STORAGE,
                    REQUEST_EXTERNAL_STORAGE
            );
        }
    }
Checks if the app has permission to write to device storage
<p/>
If the app does not has permission then the user will be prompted to grant permissions

@param activity the activity from which permissions are checked
SignaturePad-Example/src/main/java/com/github/gcacace/signaturepad/MainActivity.java