I want to download a large (zip file) from my server. This is about 440 MB. I am using the Android download service.
Here is my code:
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Request request = new Request(Uri.parse(SERVER_PATH));
request.setTitle(getString(R.string.title_download));
request.setDescription(getString(R.string.desc_download));
File mapDir = new File(Environment.getExternalStorageDirectory() + DEVICE_PATH_PART);
File mapPartFile = new File(Environment.getExternalStorageDirectory() + DEVICE_PATH_PART + MAP_PACKFILE + EXT_INPROGRESS);
request.setDestinationUri(Uri.fromFile(mapPartFile));
enqueue = dm.enqueue(request);
Download will start normally. I can see the file in the download manager. But when there are some problems with the network (disconnection), the completion of the download with error 1008 and the partial file are deleted from my directory . And this is my problem and question:
How can I make the download service not partially delete the file from my destination directory in order to resume the download process?
Side question or problem: when I download a 440-megapixel file from my application, the download process breaks many times (with the error of resume resume and after that without the ability to resume downloading). But if I upload the same file through the application manager application directly in android, everything is fine. And I do not know why. The only error I get in the receiver is 1008 about resuming work. Does anyone have the same problem?
Thanks.
source
share