https://m.blog.naver.com/PostView.nhn?blogId=trylsj&logNo=220902287282&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F



boolean isGrantStorage = grantExternalStoragePermission();

if(isGrantStorage){
// 일반처리.
}



private boolean grantExternalStoragePermission() {
    if (Build.VERSION.SDK_INT >= 23) {

        if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            Log.v(TAG,"Permission is granted");
            return true;
        }else{
            Log.v(TAG,"Permission is revoked");
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);

            return false;
        }
    }else{
        Toast.makeText(this, "External Storage Permission is Grant", Toast.LENGTH_SHORT).show();
        Log.d(TAG, "External Storage Permission is Grant ");
        return true;
    }

}


@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (Build.VERSION.SDK_INT >= 23) {
    if(grantResults[0]== PackageManager.PERMISSION_GRANTED){
        Log.v(TAG,"Permission: "+permissions[0]+ "was "+grantResults[0]);
        //resume tasks needing this permission
    }
    }
}