1
我试图加载在我的资产的图像文件夹命名为“foo.png”:无法从资产文件夹filenotfoundexception加载png?
AssetManager assetManager = context.getAssets();
InputStream is = assetManager.open("foo.png");
这工作对我的Nexus 5,当我尝试在Galaxy Nexus的罚款,我得到一个异常:
java.io.FileNotFoundException:
/images/foo.png: open failed: ENOENT (No such file or directory)
我不知道为什么星系连接处的“/ images /”部分被添加到路径中?如果我在两部手机上做了文件列表,他们都同意:
String[] files = assetManager.list("");
for (String name : files) {
Log.e(TAG, "File: [" + name + "].");
}
// prints "foo.png" on both phones.
不确定为什么会有这种差异?
好的问题,为什么一个错误抛出......不知道为什么。但是,为什么要使用资源文件夹,而不是图像的res/drawable? – Submersed