Whenever i try to download any file through the code below
dm = (DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE);
request = new Request(
Uri.parse(finalurl));
enqueue = dm.enqueue(request);
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
long downloadId = intent.getLongExtra(
DownloadManager.EXTRA_DOWNLOAD_ID, 0);
Query query = new Query();
query.setFilterById(enqueue);
Cursor c = dm.query(query);
if (c.moveToFirst()) {
int columnIndex = c
.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex)) {
Toast.makeText(context, "download finished", Toast.LENGTH_LONG).show();
}
}
}
}
};
context.registerReceiver(receiver, new IntentFilter(
DownloadManager.ACTION_DOWNLOAD_COMPLETE));
The file downloaded shows in Download Manager Application and can be played from there any time but that is not storing the downloaded file in Downloads folder.
If i use
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "filename.extention"));
i get the same result.
My question is- Where are my downloads going and how can i bring them to downloads folder?