I am working on application,there i have to download some images from the server for the fist time of running, the issue is at the of download, if network connection fails the download interrupted at middle,then the partly downloaded not able to access from the application. i want to delete that type of files automatically. help me please
Asked
Active
Viewed 624 times
2
-
Are you also looking for a way to resume the download rather than ditch it and start over? – TryTryAgain Mar 09 '12 at 07:42
-
In your running download when you detect the internet stops then in catch u need to delete the file : for internet check you get socketException... try..hop it works – Mayur Bhola Mar 09 '12 at 07:45
1 Answers
0
if(isInterrupted())
{
// the download was canceled or interrupted, so let's delete the partially downloaded file
outFile.delete();
}
else
{
// notify completion
msg = Message.obtain(parentActivity.activityHandler,
AndroidFileDownloader.MESSAGE_DOWNLOAD_COMPLETE);
parentActivity.activityHandler.sendMessage(msg);
}
taken from: http://www.hassanpur.com/blog/2011/04/android-development-downloading-a-file-from-the-web/
EDIT (additional info): If you wanted to resume the file download instead of deleting and restarting, take a look at this SO post how to resume an interrupted download

Community
- 1
- 1

TryTryAgain
- 7,632
- 11
- 46
- 82