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();