title: How to set progress bar when upload a file transfer to server
body: <p>How to create a progress bar when upload file to server in android.I am given below this code please help me.....When transfer my data to show a progress bar....Please solve my problem..This is my uploading file class...</p>
  
  <pre><code>    public void doFileUpload(File file) {
  
  
                  FTPClient client = new FTPClient();
  
                  try {  
                      client.connect(FTP_HOST,21);
                      Log.e("clientconnect", "" + client);
                      client.login(FTP_USER, FTP_PASS);
                      Log.e("clientlogin", "" + client);
                      client.setType(FTPClient.TYPE_BINARY);
                      Log.e("clienttype", "" + client);
                      client.changeDirectory("/gg1/");
                      Log.i("", "$$$$$$$$$$$$$$$$$" + ("/gg1/"));
  
  
                      client.upload(file,new MyTransferListener());
                      Log.e("filenameupload", "" + file);
  
  
  
                  } catch (Exception e) {
                      e.printStackTrace();
                      try {
                          client.disconnect(true);
                      } catch (Exception e2) {
                          e2.printStackTrace();
                      }
                  }
  
              }
  
          public class MyTransferListener implements FTPDataTransferListener {
  
              public void started() {
  
                  Toast.makeText(getBaseContext(), " Upload Started ...",
                          Toast.LENGTH_SHORT).show();
  
              }
  
              public void transferred(int length) {
  
  
                  Toast.makeText(getBaseContext(), " transferred ..." + length,
                          Toast.LENGTH_SHORT).show();
  
              }
  
              public void completed() {
  
  
                  Toast.makeText(getBaseContext(), " completed ...",
                          Toast.LENGTH_SHORT).show();
  
  
              }
  
              public void aborted() {
  
  
                  Toast.makeText(getBaseContext(),
                          " transfer aborted , please try again...",
                          Toast.LENGTH_SHORT).show();
  
              }
  
              public void failed() {
  
  
                  System.out.println(" failed ...");
              }
  
          }
  </code></pre>