DownloadManager不在下载文件夹中存储下载的文件 [英] DownloadManager not storing Downloaded files in Download Folder
问题描述
每当我尝试通过下面的代码下载任何文件
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));
下载的文件显示在Download Manager Application中,可以随时从那里播放,但是不会将下载的文件存储在Downloads文件夹中.
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.
如果我使用
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "filename.extention"));
我得到相同的结果.
我的问题是-我的下载要去哪里,如何将它们带到下载文件夹?
My question is- Where are my downloads going and how can i bring them to downloads folder?
推荐答案
要查看下载的文件,您必须在手机中安装文件管理器"应用程序.查看下载文件的步骤:
To see the downloaded files, you must have File Manager app installed in your phone. Steps to view downloaded files:
- 打开文件管理器应用程序.
- 转到存储-> sdcard
- 转到Android->数据->您的包名称",例如com.xyx.abc
- 这是您的所有下载内容.
路径为:storage/sdcard/Android/data/您的包"
Path is: storage/sdcard/Android/data/"your package"
使用以下方法将文件保存在下载文件夹中
Use below methos to save files in Download folder
.setDestinationInExternalFilesDir(this, dir, "abc.png");
这篇关于DownloadManager不在下载文件夹中存储下载的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!