Android Multiple permission easy way

private static final int PERMISSION_REQUEST_CODE = 1;
  if(checkPermission()){
            // task after permission granted.
        } else {
            requestPermission();
        }
private boolean checkPermission(){
        int result = ContextCompat.checkSelfPermission(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (result == PackageManager.PERMISSION_GRANTED){

            return true;

        } else {

            return false;
        }
    }
 private void requestPermission(){

        ActivityCompat.requestPermissions(this,new String[]{
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE
        },PERMISSION_REQUEST_CODE);

    }
 
    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        switch (requestCode) {
            case PERMISSION_REQUEST_CODE:
                if (grantResults.length > 0 && grantResults[0] + grantResults[1] == PackageManager.PERMISSION_GRANTED) {

                        startDownload();
                } else {

                    Snackbar.make(findViewById(R.id.coordinatorLayout),"Permission Denied, Please allow to proceed !", Snackbar.LENGTH_LONG).show();

                }
                break;
        }

Android Download PDF file and Save to Downloads folder and Open it with a PDF Viewer

Download PDF file and Store it to Downloads folder

DownloadManager downloadmanager;
    Environment
            .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
            .mkdirs();

    downloadmanager = (DownloadManager) getApplication().getSystemService(Context.DOWNLOAD_SERVICE);
    String url = hardcode + bb ;
    Uri uri = Uri.parse(url);
    DownloadManager.Request request = new DownloadManager.Request(uri)
            .setTitle(bb )
            .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
                    bb)
            .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    Log.i("Download1", String.valueOf(request));
    downloadmanager.enqueue(request);

Open PDF file from Downloads folder and show it on a PDF viewer

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator +
            "YOUR FILE NAME");
    Uri path = Uri.fromFile(file);
    Log.i("Fragment2", String.valueOf(path));
    Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW);
    pdfOpenintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    pdfOpenintent.setDataAndType(path, "application/pdf");
    try {
        this.startActivity(pdfOpenintent);
    } catch (ActivityNotFoundException e) {

    }