Using DownloadManager for incognito downloads

217 Views Asked by At

Can I use android.app.DownloadManager to download files that will be accessible (and visible) only to my application?

The solution should work for API 9 (2.3), if there is a 3rd party library that will achieve the same as DM then please let me know as well.

1

There are 1 best solutions below

5
On

Not directly. By default, downloads are saved to a generated filename in the shared download cache and may be deleted by the system at any time to reclaim space.

You can register a BroadcastReceiver to get notified when the download is complete. In this receiver, you can get the path of the downloaded file and copy it to internal storage yourself. Then, you can delete the file from the default path.

See this tutorial for an example about receiving a download complete broadcast and responding to it.