我正在使用带有DownloadManager的URL下载pdf文件。使用提供的链接/ URL成功下载文件。状态在通知中也可见,下载后,可以打开和查看pdf。我还使用以下代码设置文件目的地:
request.setDestinationInExternalFilesDir(DownloadActivity.this, Environment.DIRECTORY_DOWNLOADS,"pdf1.pdf");
现在,问题是,文件正在下载,但我在下载文件夹中找不到该文件。我基本上想要干掉我下载文件的路径。这是我的整个代码:
downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(URL);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(DownloadActivity.this, Environment.DIRECTORY_DOWNLOADS,"pdf1.pdf");
Long ref = downloadManager.enqueue(request);
要获取下载文件的路径,我需要做哪些更改?非常感谢。
为什么不记录Environment.DIRECTORY_DOWNLOAD来检查路径
在存储数据之前,尝试请求权限,读取和写入