Reputation: 5135
i am developing one application for displaying images and labels and its sound.i want to get this info from xml .where i need to keep xml file in android project how to get values from that xml file
Thanks in advance
Aswan
Upvotes: 0
Views: 865
Reputation: 24472
You can package the xml file in assets/
directory inside your apk. With that, you can use
AssetManager assets = context.getAssets();
InputStream in = assets.open("myfile.xml");
If your file just contains labels, or strings, you can save it in put it in res/values/strings.xml
inside your apk. In this case you can access the string values using the android generated R
class
If you have a custom file (with custom structure) you can use DOM, SAX, or Xml Pull to read those files. e.g.
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(in);
Upvotes: 1