android - 如何从android的应用程序缓存中打开和读取这个文件?
问题描述
我的应用程序在此位置创建一个文件
绝对路径
/data/user/0/in.eaft.contentsecurityplayer/cache/.\epub\A-Room-with-a-View-morrison.epub\
规范路径
/data/data/in.eaft.contentsecurityplayer/cache/.\epub\A-Room-with-a-View-morrison.epub
我需要将真实路径传递给这个库,以便它打开 epub 文件
我需要打开这个文件
folioReader.setConfig(config, true)
.openBook(filePath);
如果我传递像/storage/sample.epub这样的文件路径,它会打开,但是当我传递上述路径时,文件没有打开。
如何从缓存目录中打开此文件?
解决方案
您需要添加以下代码,因为它是基于上下文的:
String cacheDir = context.getCacheDir();
这将为您提供路径
推荐阅读
- visual-studio-code - VSCode 扩展上使用的符号和数字
- reactjs - 为什么 useEffect 可能会在 SetInterval 效果上返回 ClearInterval()?
- python - 查找所有组值为 nan 的行
- javascript - 发现每个产品网址
- node.js - Firebase Cloud Functions:“解析函数触发器时出错”
- java - javax.net.ssl.SSLHandshakeException:没有合适的协议(协议被禁用或密码套件不合适
- node.js - 无法使用 sinon 模拟 ioredis 连接
- python - 如何通过 anaconda prompt 升级 conda 版本?
- assembly - 如何将 bool 数组(0 或 1 字节)转换为二进制整数?
- java - 无法在不四舍五入的情况下在 BigDecimal Java 中执行除法运算