I am using the DownloadManager
to download my App-Files.
If I put an url a second time into the DownloadManager
it downloads the file and puts a -1 filename-1.file
at the end. Is there a way to just not let the DownloadManager
download it again? Or do I have to check that by myself?
Code:
private void downloadImages(final List<SomeClass> data) {
RuntimeExceptionDao<SomeClass, Integer> someDao = DatabaseAdapter.getInstance().getSomeDao();
DownloadManager downloadmanager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
for(SomeClass someClass : data){
DownloadManager.Request request = getRequest(someClass);
someClass.mDownloadId = downloadmanager.enqueue(request);
someDao.createOrUpdate(someClass);
}
}
private DownloadManager.Request getRequest(SomeClass someClass) {
Uri uri = Uri.parse(someClass.mImage);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
request.setVisibleInDownloadsUi(false);
request.setDestinationInExternalFilesDir(mContext, Environment.DIRECTORY_DOWNLOADS, car.getFileName());
return request;
}