Question

I am trying to create a custom download activity/page, and I plan to build it on top of the Android DownloadManager. But seems DownloadManager has no public sorting options, all the sorting stuff is hidden, is there a way around this? I'd like to sort by date, or file size.

Thanks,

Johnny

Was it helpful?

Solution

In source code you can find that DownloadManger. Query can only be sorted by lastModifyDate. So I use the way to extract using source code of DownloadManger and rewrite its sorted method.

Using like this:

AppDownloadManager.Query query = new AppDownloadManager.Query();
query.setFilterByStatus(AppDownloadManager.STATUS_PENDING | AppDownloadManager.STATUS_PAUSED | AppDownloadManager.STATUS_RUNNING | AppDownloadManager.STATUS_FAILED);
query.orderBy(AppDownloadManager.COLUMN_ID, AppDownloadManager.Query.ORDER_DESCENDING);

It's first time I answer question in StackOverFlow and I think my English is poor .tks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top