I'm starting a 2Gb file download using the DownloadManager, and in doing so I offer the user the option to pick where they want to save that file: internal storage or SD card. Also, I give the user an option to cancel said download. Here is my code:
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(downloadId);
Cursor cursor = downloadManager.query(query);
try {
if (cursor.moveToFirst()) {
int status =cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
if (status == DownloadManager.STATUS_RUNNING ||
status == DownloadManager.STATUS_PENDING) {
downloadManager.remove(downloadId);
}
}
} finally {
cursor.close();
}
My problem: when downloading to internal storage, the .remove(downloadId) call works instantly, and the download stops. But when downloading to the SD Card (on a Samsung Galaxy S7 Edge), using the same code, it takes 3-5 minutes to stop the download.
Any ideas on removing that delay?
Edit: some paths examples, returned by Activity.getExternalFilesDirs():
/storage/emulated/.../ - this is internal
/storage/0123-4567/.../ - this is the SD Card