我已经将一些epub文件保存到了安卓的内存中。我一直使用folioReader库来显示此文件,但它一直告诉我路径目标为空。
因此,我查看了android studio的Device File Explorer,找到了如下位置的文件:/data/data/packageName/files/FileName
我使用以下代码来获取路径:
try{
String path = getFilesDir().getPath() + "/" + fileName
folioReader.openBook(path);
Log.i("Path:", path);
} catch (Exception e){
e.printStackTrace();
}
}它在我的log cat:上返回以下路径
/data/user/0/packageName/files/fileName位置路径似乎有所不同。
所以,我的问题是:我如何找到这个位置的路径?
/data/data/packageName/files/FileName发布于 2021-12-03 16:51:16
private String getFilePath(){
ContextWrapper contextWrapper = new ContextWrapper(getApplicationContext());
File filePath = contextWrapper.getFilesDir();
File file = new File(filePath,"fileName" +"*/*");
return file.getPath();
}在这里,'filePath‘包含'/data/data/packageName/files/’位置,然后将其与'/fileName‘连接,得到该文件的完整存储路径
*/ *告知'fileName‘可以是任何文件类型
https://stackoverflow.com/questions/57243209
复制相似问题