我找到了很多与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/