Android examples for XML:XML Resource
read XML from Resource
//package com.java2s; import android.content.res.Resources; import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readXML(Resources res, String file) { BufferedReader in = null; try {// w ww . j a va 2 s . co m in = new BufferedReader(new InputStreamReader(res.getAssets() .open(file))); String line; StringBuilder buffer = new StringBuilder(); while ((line = in.readLine()) != null) buffer.append(line).append('\n'); return buffer.toString(); } catch (IOException e) { return ""; } finally { closeStream(in); } } private static void closeStream(Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { } } } }