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?
Fix Downloads Not Showing up on Windows 10 You can click "Show in folder" to check the accurate save location. To change the default storage location, go to "Settings" > "Downloads" > "Location" > click "Change" to complete. The approach is similar to change the location of files downloaded by other browsers.
You can find your files, downloaded by Chrome, by using any File Manager. In case the Downloads folder is missing, Chrome automatically saves data in the /storage/Android/data folder. You just need to find the Chrome folder in there and all previously downloaded files should be inside.
Try
request.setDestinationInExternalPublicDir("/folder","file.ext");
This will save the file to
Environment.getExternalStorageDirectory() + "/folder"
To see the downloaded files, you must have File Manager app installed in your phone. Steps to view downloaded files:
Path is: storage/sdcard/Android/data/"your package"
Use below methos to save files in Download folder
.setDestinationInExternalFilesDir(this, dir, "abc.png");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With