Whenever I try to upload 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 downloaded file is displayed in the Download Manager application and can be played from there at any time, but does not save the downloaded file in the Downloads folder.
If i use
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "filename.extention"));
I get the same result.
My question is: Where do my downloads go and how can I bring them to the download folder?
source
share