In android, how can I calculate the size of a data which I download or upload from internet?
Asked
Active
Viewed 982 times
2 Answers
1
For uploading you might know the filesize. for example:
FileInputStream fileInputStream = new FileInputStream(sourceFile);
int uploadSizeBytes = fileInputStream.available();
For download you may calculate it from loop while reading.
such as:
while(stream.read() != -1){
bytesRead++ ;
}

Riad
- 3,822
- 5
- 28
- 39