tags:

views:

41

answers:

2

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

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?

A: 

I think this method will solve your problems. At least I'm doing it that way:

http://developer.android.com/reference/android/content/res/Resources.html#getIdentifier%28java.lang.String,%20java.lang.String,%20java.lang.String%29

Roflcoptr
+2  A: 

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

success_anil
Thanks anil......
Shalini Singh