Android Studio DownloadManager deletes File after download

43 views Asked by At

I download Files with the DownloadManager and actually these files are deleted after downloading. My search didn't get any results (as far as I can see) so I hope to get some help here.

DownloadManager downloadmanager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
            Uri uri = Uri.parse("https://mysite/file");
            DownloadManager.Request request = new DownloadManager.Request(uri);
            request.setDestinationInExternalFilesDir(PDFActivity.this, "/Download/", "file.pdf");
            downloadmanager.enqueue(request);
            registerReceiver(onDownloadComplete, new IntentFilter(downloadmanager.ACTION_DOWNLOAD_COMPLETE));
BroadcastReceiver onDownloadComplete=new BroadcastReceiver() {
        public void onReceive(Context ctxt, Intent intent) {
            unregisterReceiver(onDownloadComplete);
        }
}

This is the short version of my code. Can anyobdy explain what's the problem and give me some advice?

Greetings, Chris

0

There are 0 answers