I found how to resume the download without reading the previous data
using an HTTP Range request. For others that need to do this, the
modified code is:
URL url = new URL(mInternetUrl);
HttpURLConnection connection =
(HttpURLConnection)url.openConnection
();
if (mLocalFileSize > 0) {
connection.addRequestProperty("Range", "bytes=" +
mLocalFileSize +
"-");
}
connection.connect();
int responseCode = connection.getResponseCode();
switch (responseCode) {
case HttpURLConnection.HTTP_OK:
mLocalFileSize = 0;
mInternetFileSize = connection.getContentLength();
break;
case HttpURLConnection.HTTP_PARTIAL:
// The server supports resume
mInternetFileSize = connection.getContentLength() +
mLocalFileSize;
break;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---