smanikandan14 / ThinDownloadManager

To download files and to avoid using DOWNLOAD_WITHOUT_NOTIFICATION permission if you are using Android's DownloadManager in your apps.
Apache License 2.0
783 stars 185 forks source link

cleanupDestination? Files getting deleted after download?I have downloaded same picture. #112

Open VikasPawar2112 opened 6 years ago

VikasPawar2112 commented 6 years ago

I want to download duplicate pictures and save them as picid(1),picid(2) etc. I used to same url to download picture and i am saved the those picture as picture id. So, they don't save into gallery. It show D/ThinDownloadManager: cleanupDestination() deleting /storage/emulated/0/Pictures/ShareApp/Pic74402848.jpg So, it's possible to download duplicate pictures.

Here is my code: public void download(List pictureList) { this.pictureList = pictureList; Random random = new Random(); for (Picture picture : pictureList) { RetryPolicy retryPolicy = new DefaultRetryPolicy(); Uri downloadUri = Uri.parse(picture.getPicUrl()); DownloadPictures.downloadIssue("Before Downloaded Picture Name" + picture.getPicUrl()); String fileName = "Pic" + picture.getPicId()/System.currentTimeMillis() + random.nextInt()/ + ".jpg"; Uri destinationUri = Uri.parse(shareAppFile + "/" + fileName); DownloadRequest downloadRequest1 = new DownloadRequest(downloadUri) .setDestinationURI(destinationUri).setPriority(DownloadRequest.Priority.LOW) .setRetryPolicy(retryPolicy) .setDownloadContext(picture.getPicId()) .setStatusListener(downloadStatusListenerV1); downloadRequests.add(downloadManager.add(downloadRequest1)); } }