Ani Ani - 1 month ago 20
Android Question

Android DownloadManager using for ByteStream

Can we use DownloadManager to download the bytestream. I have to download a PDF bill which is a bytestream and after download, I want to create a file. I can do it with a file but not with bytestream. has anyone does that?

Answer

You cannot read the bytestream but once the file is downloaded by DownloadManager, it would be saved in Downloads directory or application's private directory. You can create a broadcast receiver which takes following intent action.

 DownloadManager.ACTION_DOWNLOAD_COMPLETE

In Broadcast receiver, you can read the downloaded file from directory. You have query in downloads db with last download id. After getting downloaded file URI, you can read the file through bytestream.