title: Progress bar in listview while AsyncTask file download
body: <p>I am having a strange issue, I have a new asynctask launced whenever i find an MP3 file on webbrowser, and lauch a progress bar in the listview for each AsyncTask. So number of downloads can be more than 1 and simultaneous. But now whenever Asynctask is launced ProgressBar moves same for all and not different for different AsyncTask, Plz guide me.......</p>
  
  <p><img src="https://i1106.photobucket.com/albums/h375/vismessenger/Capture.png" alt="LISTVIEW WITH PROGRESS BAR"></p>
  
  <pre><code>    public class CopyOfDownloadsListActivity extends ListActivity {
      /** Called when the activity is first created. */
  
  //  static ArrayList&lt;String&gt; pthreads = new ArrayList&lt;String&gt;();
  ImageView bt;
  ProgressBar pb;
  ListView allList;
  TextView tv;
  String fileName;
  String mp3URL;
      URL url2;
      int filecount  = 0;
  
  private class DownloadFile extends AsyncTask&lt;String, Integer, Void&gt;{
      MyCustomAdapter adapter;
  
      int count = 0;
      ProgressDialog dialog;
      ProgressBar progressBar;
      int myProgress;
  
     @Override        
      protected Void doInBackground(String... u) {        
          try {                   
              URL ul = new URL(u[0]);
              Log.i("UI",ul.toString());
         //   int len = CopyOfMusicDownloader.mp3urls.size();
         //   URL url2 = new URL(CopyOfMusicDownloader.mp3urls.get(len-1));
              HttpURLConnection c = (HttpURLConnection) ul.openConnection();
              c.setRequestMethod("GET");
              c.setDoOutput(true);
              c.connect();
  
              int lengthOfFile = c.getContentLength();
  
              String PATH = Environment.getExternalStorageDirectory()
                      + "/download/";
              Log.v("", "PATH: " + PATH);
              File file = new File(PATH);
              file.mkdirs();
  
              fileName = "Track";
              filecount++;
  
              fileName =  fileName + Integer.toString(filecount) + ".mp3";
  
  
              File outputFile = new File(file, fileName);
              FileOutputStream fos = new FileOutputStream(outputFile);
              InputStream is = c.getInputStream();
  
              byte[] buffer = new byte[1024];
              int len1 = 0;      
              while ((len1 = is.read(buffer)) != -1) {
                  myProgress = (int)((len1/lengthOfFile)*100);
                  myProgress = myProgress + myProgress;
                  Log.i("lengthOfFile", Integer.toString(lengthOfFile));
                  Log.i("My Progress", Integer.toString(myProgress));
                  publishProgress(myProgress);
                  fos.write(buffer, 0, len1);
              }
              fos.close();
              is.close();
  
              }catch (IOException e) {
                     e.printStackTrace();
              }
          return null;
      }
  
      protected void onPostExecute() {
      }
  
      @Override
      protected void onPreExecute() {         
            adapter = new MyCustomAdapter(CopyOfDownloadsListActivity.this, R.layout.row, CopyOfMusicDownloader.mp3urls);
            setListAdapter(adapter);
      }
  
  
  
      @Override
      protected void onProgressUpdate(Integer... values) {
           Log.i("Value", values[0].toString());
           count++;
           adapter.notifyDataSetChanged();
      }
  
  
      public class MyCustomAdapter extends ArrayAdapter&lt;String&gt; {     
          public MyCustomAdapter(Context context, int textViewResourceId, ArrayList&lt;String&gt; pthreads) {
          super(context, textViewResourceId, pthreads);
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
                  LayoutInflater inflater = getLayoutInflater();
                  View row = inflater.inflate(R.layout.row, parent, false);
                  bt =(ImageView)row.findViewById(R.id.cancel_btn);
                  tv =(TextView)row.findViewById(R.id.filetext);
                  pb = (ProgressBar)row.findViewById(R.id.progressbar_Horizontal);
                  pb.setProgress(count);  
                  return row;
              }
          }       
   }  
  </code></pre>
  
  <p>This is the AsyncTask start, and its onCreate
                  new DownloadFile().execute(url2.toString());</p>