缓存目录 : Failed to find configured root that contains 的 Android FileProvider

标签 android caching android-7.0-nougat android-fileprovider android-7.1-nougat

我找到了很多与FileProvider相关的链接,但我没有找到缓存目录的解决方案

java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/pkg name/cache/1487876607264.png

我想将它用于 CACHE DIRECTORY,如何在 provider 中提供路径。

<paths>
    <external-path name="external_files" path="."  />
</paths>

我把它用作:

File file = new File(context.getCacheDir(), System.currentTimeMillis() + ".png");

Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file);

如果我提供应用程序文件夹路径,它可以正常工作,但不能使用 缓存目录。

有什么帮助吗?

最佳答案

使用 <cache-path> ,而不是 <external-path> .见 the documentation .

关于缓存目录 : Failed to find configured root that contains 的 Android FileProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42424248/

相关文章:

java - 外部文件夹中的 Hazelcast 设置

c++ - 缓存重复输入数据的表达式评估

android - RenderScript:无法打开共享库:(空)

android - "ul"、 "li"的 Android N 中未调用 Html 标记处理程序

Android:使用 DrawableCompat 进行着色

java - 表达式的类型必须是数组类型,但它解析为 int

Android webkit 和电池消耗

Android ICS 与 JQuery Mobile1.0 兼容性问题

ruby-on-rails - 为什么Rails.cache不是线程安全的?

android - 作业计划程序未在 Android N 上运行