Skip to content

Instantly share code, notes, and snippets.

@ledzep9012
Last active January 15, 2017 06:47
Show Gist options
  • Save ledzep9012/b8593647bd7ede9b3a60646a3cb82f17 to your computer and use it in GitHub Desktop.
Save ledzep9012/b8593647bd7ede9b3a60646a3cb82f17 to your computer and use it in GitHub Desktop.
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
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment