4

I am trying to make my app save files to the local Downloads folder. The Problem is, that they are not visible when using the "Downloads App" (They are visible when i use a different filemanager).

As already mentioned here https://stackoverflow.com/a/28184936/5595421 it seems to be because the files weren't actually "downloaded".

So I tried to start a download with a local file Uri, what leads to illegal argument Exception because it appears that DownloadManager can only handle http Uri's.

Cœur
  • 37,241
  • 25
  • 195
  • 267
grees
  • 141
  • 2

1 Answers1

0

You can actually make your files visible without downloading with the DownloadManager, but just notifying it using addCompletedDownload.

DownloadManager dm = (DownloadManager) mService.getSystemService(DOWNLOAD_SERVICE);
dm.addCompletedDownload(title, description, isMediaScannerScannable, mimeType, path, length, showNotification);

In case you'll want to disable the download notification, you would also need to add the permission for it:

<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
Shlomi
  • 343
  • 5
  • 23