Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import android.app.Activity; public class Main { public static String getCofigValue(Activity activity, String filename, String keyName) { String ret = ""; InputStream is = activity.getClass().getResourceAsStream(filename); if (is != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } Document doc = null; try { doc = builder.parse(is); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } doc.normalize(); NodeList list = doc.getElementsByTagName(keyName); if (list != null && list.getLength() > 0) { ret = list.item(0).getFirstChild().getNodeValue(); } } return ret; } }