title: Download video from Firebase storage by URL
body: <p>I uploaded video to Firebase storage. 
  I have the URL for the video. 
  In my app, I have a download button.
  I want to simply download the video to mobile storage.</p>
  
  <p><strong>Here is the URL</strong></p>
  
  <pre><code>String videoUrl = "https://firebasestorage.googleapis.com/v0/b/whatsappstatus-b23a0.appspot.com/o/videos%2F__-1__2__content_____media__external__video__media__123759__ORIGINAL__NONE__1830167854?alt=media&amp;token=ff6db9ff-dd83-44f0-9beb-4578455abd3f"
  </code></pre>
  
  <p>In the <code>oncreate</code> method, I'm calling </p>
  
  <pre><code>      new ProgressBack().execute("");
  </code></pre>
  
  <p><strong>This is what I have done</strong></p>
  
  <pre><code>   class ProgressBack extends AsyncTask&lt;String,String,String&gt; {
          ProgressDialog PD;
  
          @Override
          protected void onPreExecute() {
              PD = ProgressDialog.show(VideoDetailActivity.this, null, "Please Wait ...", true);
              PD.setCancelable(true);
          }
  
          @Override
          protected String doInBackground(String... arg0) {
              downloadFile(videoUrl, "Sample.mp4");
  
              return null;
          }
  
          protected void onPostExecute(Boolean result) {
              PD.dismiss();
  
          }
      }
  
  
     private void downloadFile(String fileURL, String fileName) {
      try {
          String rootDir = Environment.getExternalStorageDirectory()
                  + File.separator + "Video";
          File rootFile = new File(rootDir);
          rootFile.mkdir();
          URL url = new URL(fileURL);
          HttpURLConnection c = (HttpURLConnection) url.openConnection();
          c.setRequestMethod("GET");
          c.setDoOutput(true);
          c.connect();
          FileOutputStream f = new FileOutputStream(new File(rootFile,
                  fileName));
          InputStream in = c.getInputStream();
          byte[] buffer = new byte[1024];
          int len1 = 0;
          while ((len1 = in.read(buffer)) &gt; 0) {
              f.write(buffer, 0, len1);
          }
          f.close();
      } catch (IOException e) {
          Log.d("Error....", e.toString());
      }
  }
  </code></pre>
  
  <p>I don't know what I am missing here.</p>