Android下载管理器文件已下载位置

时间:2018-01-12 18:17:17

标签: android android-download-manager android-external-storage

我在我的清单中添加了用户权限WRITE_EXTERNAL_STORAGE并设置了下载位置request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,fileType),但仍然将文件下载到(/data/user/0/com.android.providers.downloads/cache。设置存储的DOWNLOADS文件夹目录的路径?请帮忙。我的代码如下:

downloadManager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(myUrl));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
String fileType = URLUtil.guessFileName(myUrl, null, MimeTypeMap.getFileExtensionFromUrl(myUrl));
Long reference = downloadManager.enqueue(request);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileType);

0 个答案:

没有答案