无法获取下载路径

问题描述 投票:0回答:2

我正在使用带有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);

要获取下载文件的路径,我需要做哪些更改?非常感谢。

java android pdf android-download-manager
2个回答
0
投票

为什么不记录Environment.DIRECTORY_DOWNLOAD来检查路径


0
投票

在存储数据之前,尝试请求权限,读取和写入

© www.soinside.com 2019 - 2024. All rights reserved.