title: How to download file from firebase storage url to internal storage
body: <p>I want to download the pdf file from URL, I'm unable to download it shows  Unsupported path. how to set the correct path.</p>
  
  <pre><code> public void downloadAndOpenPdf(String url){
  
          String fileName = url.substring(url.lastIndexOf('/')+1, url.length());
          file = new File(Environment.getDataDirectory(), fileName);
  
              if(!file.isFile()) {
                  DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                  DownloadManager.Request req = new DownloadManager.Request(Uri.parse(url));
                  req.setDestinationUri(Uri.fromFile(file));
                 // req.setTitle("Some title");
  
                  BroadcastReceiver receiver = new BroadcastReceiver() {
                      @Override
                      public void onReceive(Context context, Intent intent) {
                          unregisterReceiver(this);
                          if (file.exists()) {
                              openPdfDocument(file);
                          }
                      }
                  };
                  registerReceiver(receiver, new IntentFilter(
                          DownloadManager.ACTION_DOWNLOAD_COMPLETE));
                  dm.enqueue(req);
                  Toast.makeText(this, "Download started", Toast.LENGTH_SHORT).show();
              }
              else {
                  openPdfDocument(file);
              }
          }
  
          public boolean openPdfDocument(File file) {
              Intent target = new Intent(Intent.ACTION_VIEW);
              target.setDataAndType(Uri.fromFile(file), "application/pdf");
              target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
              try {
                  startActivity(target);
                  return true;
              } catch (ActivityNotFoundException e) {
                  Toast.makeText(this,"No PDF reader found",Toast.LENGTH_LONG).show();
                  return false;
              }
  
          }
  </code></pre>