阅读来自Android的资产文件夹中的XML文件 [英] Read xml file from Android Asset folder
本文介绍了阅读来自Android的资产文件夹中的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图读取相同的文件的 xmlfile.xml 的从资产文件夹,并从SD卡的另一个副本 SD卡/下载/
I'm trying to read the same file "xmlfile.xml" from the assets folder and also another copy from the SD card sdcard/download/.
我可以从SD卡读取:
- unfile返回真
- 在册返回真
- unfile Return True
- Esite Return True
我不能没有从资产文件夹阅读:
I can't not Read from Assets folder:
- unfile返回假
- 在册返回假
- unfile Return False
- Esite Return False
这code金正日无法正常工作
This code il NOT Working
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();
}
这code IL工作
This code il Working
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();
}
有人能解释我如何可以读取从资产文件夹中的文件。
someone can explain me how can I read the file from the Assets folder.
谢谢 马可
推荐答案
要打开你需要下面这段code资产:
To open an asset you'd need the following piece of code:
InputStream is = getAssets().open("xmlfile.xml")
这篇关于阅读来自Android的资产文件夹中的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文