title: Android - Downloading File by updating Progress Bar
body: <p>I have multiple files in dropbox account. I am successfully downloading files. But I want to show the progress bar with the percentage so when all files gets downloaded.The progress bar finishes.I am using AsyncTask for downloading files.here is my code. </p>
  
  <pre><code>public void onPreExecute(){
  
          mDialog = new ProgressDialog(mContext);
          mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
          mDialog.setMax(100);
          mDialog.show();
      }
  
      public void downloadFiles(String filename){
          Log.i("Item Name",filename);
          File dir = null;
          Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
  
  
          if(isSDPresent){
  
          File sdCard = Environment.getExternalStorageDirectory();
           dir = new File (sdCard.getAbsolutePath() + "/AllSecure");
          if (!dir.exists()) {
              dir.mkdirs();
          }
          }else{
  
              dir = mContext.getDir("users", Context.MODE_PRIVATE); //Creating an internal dir;
              if(!dir.exists())
              {
                   dir.mkdirs();
              }     
  
          }
  
          File file = new File(dir, filename);
          try {
              FileOutputStream mFileOutputStream=new FileOutputStream(file);
  
              DropboxFileInfo mDropboxFileInxfo=mApi.getFile(PHOTO_DIR + filename, null, mFileOutputStream, null);
  
              } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              } catch (DropboxException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              }
      }
  
  
      protected String doInBackground(String... params) {
  
           SessionUtil ses = new SessionUtil(mContext);
              AndroidAuthSession session = ses.buildSession();
              mApi = new DropboxAPI&lt;AndroidAuthSession&gt;(session);
  
  
          Entry entries = null;
  
          try {
              System.out.println("mApi is " + mApi);
              entries = mApi.metadata(PHOTO_DIR, 10000, null, true, null);
          } catch (DropboxException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
  
          for (Entry e : entries.contents) {
              if (!e.isDeleted) {
                  //Log.i("Is Folder",String.valueOf(e.isDir));
                  downloadFiles(e.fileName());
                   mFileLen = entries.bytes;
                  Log.i("Item Name",e.fileName());
              }
          }
  
  
  
         return null;
      }
  
      protected void onProgressUpdate(Integer... progress) {
  
      }
  
      @Override
      protected void onPostExecute(String result) {
          mDialog.dismiss();
  
  
  
      }
  </code></pre>