我的一个客户告诉我,通过我的应用程序下载的文件不会放在下载文件夹中。它们不是下载目录,而是收集在另一个自定义目录中,类似于我的应用程序包名,比如'v2MyApp‘,我在java代码中从未提到过。我正在使用setDestinationInExternalFilesDir(f1,Environment.DIRECTORY_DOWNLOADS,fileName);
,并试图强制我的文件与Environment.DIRECTORY_DOWNLOADS一起保存在下载目录中,但为什么会发生这种情况。我没有头绪。任何建议都会很好。或者任何将它们保存在“下载”目录中的解决方案。
Thnx。
顺便说一下,问题只发生在这个客户端上,没有仿真器或任何其他设备制造它。
下载流程:
if (isOnline()) {
WebView wv = (WebView) findViewById(R.id.some_vw);
wv.loadUrl("some.url/");
wv.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDestinationInExternalFilesDir(Activity.this, Environment.DIRECTORY_DOWNLOADS,fileName);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
}
});}
发布于 2018-02-23 07:27:00
看起来你是想用setDestinationInExternalPublicDir
将下载文件的本地目的地设置为公共外部存储目录中的路径(由
getExternalStoragePublicDirectory(String)
返回)。
相对于setDestinationInExternalFilesDir
将下载文件的本地目的地设置为应用程序外部文件目录中的路径(由
getExternalFilesDir(String)
返回)。
https://stackoverflow.com/questions/48942972
复制相似问题