【发布时间】:2012-05-11 11:38:36
【问题描述】:
我正在尝试从 assets 文件夹中读取相同的文件“xmlfile.xml”,并从 SD 卡 sdcard/download/ 中读取另一个副本。
我可以从 SD 卡读取:
- unfile 返回真
- 网站返回真
我无法从 Assets 文件夹中读取:
- unfile 返回 False
- 网站返回假
这段代码不工作
File source = new File("file:///android_asset/xmlfile.xml");
boolean unfile = source.isFile();
boolean Esiste = source.exists();
try
{
// todo
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
这段代码可以正常工作
File source = new File("/sdcard/" + "download" + "/" + "xmlfile.xml");
boolean unfile = source.isFile();
boolean Esiste = source.exists();
try
{
// todo
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
谁能解释我如何从 Assets 文件夹中读取文件。
谢谢 马可
【问题讨论】:
标签: android xml android-assets