public static final int MY_PERMISSIONS_REQUEST_READ_STORAGE=10001; private void checkPermission(){ if (this.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (this.shouldShowRequestPermissionRationale(Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an explanation to the user asynchronously } else { // No explanation needed, we can request the permission. this.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_STORAGE); } } }