0

I use this code to download form internet. I want to show progress of download! To do this I need to know what amount of data has been received and ... But How should I do it?

I mean I should have buffer so that data is read into the buffer and from buffer it is put in output! and do this in Loop!

dest_File=new File(dest_FilePath);
                outputStream = new DataOutputStream(new FileOutputStream(dest_File));

                url=new URL(URL);
                urlConnection=url.openConnection();
                urlConnection.connect();
                contenLength=urlConnection.getContentLength();
                inputStream=new DataInputStream(url.openStream());
                buffer=new byte[contenLength];
                progress.setMax(contenLength);


             publishProgress((int) (total ));
             outputStream.write(buffer);

            inputStream.close();

            outputStream.flush();
            outputStream.close();
Frazz
  • 2,995
  • 2
  • 19
  • 33
ali
  • 25
  • 1
  • 5

1 Answers1

0

In the following link Android: How to run asynctask from different class file? it uses DownloadFileAsync.java class for download try this may help you

Community
  • 1
  • 1
Hasnain
  • 274
  • 2
  • 14