Andy Andy - 1 year ago 117
Android Question

xml parsing through variable file name

I have some xml files, and I keep them in

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 application.

For example:

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

String xmlName = application.xml;

How can I fetch my xml through

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download