无法访问下载文件夹中的图像

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

我面对一个奇怪的场景,当我从应用程序link_for_image打开intent时,我有5张图像,因为除了能够圈出的剩余图像,我能够获得路径,但上面链接中提到的已圈出的图像却出现了以下错误,

java.io.FileNotFoundException: /storage/emulated/0/Download/edcd36b47bdf6e9e045c72250a8bbd24.jpg

在下载文件夹中(从文件管理器打开时,带圆圈的图像不可用,可能是问题所在,这是检索图像路径的逻辑)>

 String fileName = getFilePath(context, uri);
 if (fileName != null) {
     return Environment.getExternalStorageDirectory().toString() + "/Download/" + fileName;
 }

 String id = DocumentsContract.getDocumentId(uri);
 if (id.startsWith("raw:")) {
     id = id.replaceFirst("raw:", "");
     File file = new File(id);
     if (file.exists())
         return id;
 }

 final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
 return getDataColumn(context, contentUri, null, null);

我面对一个奇怪的场景,当我从应用程序li​​nk_for_image打开intent时,我有5张图像,因为除了圈出的图像剩余图像,我都能获得路径,我的错误率低于... ...

android uri internal-storage
1个回答
0
投票
您尝试获取的图像实际上已从存储中删除,并且您的mediascanner不知道它。
© www.soinside.com 2019 - 2024. All rights reserved.