JohnRock
JohnRock

Reputation: 6875

Unexpected status from Android DownloadManager

I am getting back a status of 200 from this code:

 String status = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));

200, however, is not one of the known status codes:

DownloadManager.STATUS_PAUSED
DownloadManager.STATUS_PENDING
DownloadManager.STATUS_RUNNING
DownloadManager.STATUS_SUCCESSFUL
DownloadManager.STATUS_FAILED

So why is a 200 being returned from cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) ?

NOTE: Testing on api 10 with the same code and the same sample download file, I only see expected status values, but testing on API 14 or API 17 I am seeing the 200 status.

Upvotes: 0

Views: 167

Answers (1)

JohnRock
JohnRock

Reputation: 6875

The correct way to get the status is

int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));

Specifically, the Cursor returned from DownloadManager is a DownloadManager.CursorTranslator, which overrides getInt() for handling COLUMN_STATUS, while calling getString() just returns the raw values for that column.

Upvotes: 1

Related Questions