【发布时间】:2015-03-10 01:06:30
【问题描述】:
我正在尝试在我的应用中打开一个 .pdf。 .pdf 文件嵌入到我的应用程序中,它将在“assets”文件夹(或任何其他文件夹,如果可行的话)中提供。 该文件可以直接在 Eclipse 中打开,并且可以在 assets 文件夹内的 finder (mac) 中找到....所以我知道它在那里。
在我的代码中我有这个:
AssetManager assetManager = getAssets();
String[] files = null;
try
{
files = assetManager.list("");
}
catch (IOException e1)
{
e1.printStackTrace();
}
System.out.println("file = " + files[1]);
File file = new File(files[1]);
if (file.exists())
{
// some code to open the .pdf file
}
Tho 日志将文件名显示为“file = privacy.pdf”(我的文件),但 file.exists() 始终返回 false。
知道我做错了什么吗? 非常感谢。
【问题讨论】:
-
检查“同意”文件夹是否在正确的位置:click for info。
标签: android