Search code examples
androidandroid-contentproviderandroid-download-manager

DownloadManager with custom Uri


I have my own custom Uri which looks like:

stream://com.mydomain.myprovider/[blah-blah]

Basically it points to SQLite record with some blob

For sure I do have custom ContentProvider which handles this kind of Uri

My intention is to use DownloadManager for downloading bytes/blobs as file.

Direct try to use DownloadManager fired exception saying that supported protocol are only HTTP/HTTPS.

How to achieve my goal?


Solution

  • DownloadManager is for downloading files from the Internet using Web URLs (http and https). It is not a general-purpose "hey, let's write a file!" service.

    For your own content in your own database fronted by your own ContentProvider, write your own Java I/O code to write your own bytes to your own file.