首页 > 解决方案 > 如何从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这样的文件路径,它会打开,但是当我传递上述路径时,文件没有打开。

如何从缓存目录中打开此文件?

标签: androidfile

解决方案


您需要添加以下代码,因为它是基于上下文的:

String cacheDir = context.getCacheDir();

这将为您提供路径


推荐阅读