I'm hesitant to use HttpUrlConnection because of the increased likelihood of timing out
I'm not sure what your concern is regarding timing out. So long as you are downloading the data at a reasonable pace, I don't see why your server would give up on your connection.
Now, you may run into problems of the user moving and winding up dropping your connection (e.g., fail over from WiFi to mobile data).
and the memory footprint of a 5 MB InputStream
An InputStream
is not 5MB. For something of that size, you usually read in several KB at a time and write the results to a file.
Does 5 MB count as "long-running?"
That's up to you. It's big enough that I'd consider DownloadManager
.
It seems that the intended use of HttpUrlConnection is for small packets of data, not 5 MB of text.
HttpURLConnection
is used for everything from one byte to one terabyte and theoretically beyond. DownloadManager
probably uses HttpURLConnection
.
What DownloadManager
does for you is:
- Handle connectivity failover and picking up the download
- Keeping the device awake while the download is going on
- Etc.