title: How to download a file from Firebase Storage to the External_Storage of Android
body: <p>I have a PDF and some doc files kept in firebase storage. </p>
  
  <p>How can I download the file from Firebase Storage to the External storage of my device?</p>
  
  <pre><code>public void writeExternalStorage() {
      String filename;
      String completepath;
      mref = FirebaseStorage.getInstance().getReference();
      StorageReference filepath = mref.child("MyFiles").child("firstFile.pdf");
      InputStream inputStream = null;
      File file = null;
      FileOutputStream fileOutputStream = null;
      String state = Environment.getExternalStorageState();
      if (Environment.MEDIA_MOUNTED.equals(state)) {
          try {
              file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + "/TestPurpose");
              //  Log.d("PATH", file.toString());
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>I want to download the Firstfile.pdf file to the External_storage's Document/TestPurpose/ Folder. How it can be done??</p>