开发者

xml parsing through variable file name

I have some xml files, and I keep them in raw folder. Now, the problem is that I have to use them with variable name according to my application condition. But I don't know how to fetch them. The main thing is that I am not getting that how to give the path of my xml file in appl开发者_如何学编程ication.

For example:

My file application.xml is stored in the raw folder and I have to access it with a variable name.

String xmlName = application.xml;

How can I fetch my xml through xmlName variable?


Its not right practise to keep your general xml files in res folder. put those in assets folder. make assest folder at the same level where res folder is there in your project. Create your [name].xml file there.

access it as

InputStream in=getAssets().open("[name].xml"); String xml=convertStreamToString(in); and then use this string variable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜