Android Pause And Resume Downloading File To Sdcard
I am making an application in which I need to download a file from server and save it to sd card of android device. Apart of this there is a feature for the user to pause and resum
Solution 1:
connection.setRequestProperty("Range", "bytes=" + ***downloaded*** + "-");
Make "downloaded"
as global variable, because download start from this position.
when you press on restart button, check value of this downloaded variable,must not zero all time.
Solution 2:
This line return a wrong file size, I used the same code to open a Zip file on the net :
int lenghtOfFile = conexion.getContentLength();
How can I pause download other than by closing the output?
pauseButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
output.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
resumeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// not getting what to write here
}
});
Post a Comment for "Android Pause And Resume Downloading File To Sdcard"