FileProvider 无法从 Android 中的存储中检索图像

FileProvider can't retrieve image from storage in Android

我正在尝试从应用程序的存储中检索图像。 我有一个在 file:///data/user/0/com.myapp.android.debug/cache/cropped4227942271894219596.jpg.

中存储图像的库

我正在尝试通过执行以下操作来检索图像:

getUriForFile(context, context.applicationInfo.packageName + ".fileprovider", File(imageUri)) 但我得到的只是:

Failed to find configured root that contains /file:/data/user/0/com.myapp.android.debug/cache/cropped4227942271894219596.jpg

我的provider_paths.xml是:

<paths> <files-path name="internal_files" path="/cache" /> </paths>

有人知道问题出在哪里吗? 提前致谢!

尝试在 filepath.xml 中添加以下代码,因为需要用 cache-path

提及缓存文件
<cache-path name="cache_files" path="."  />