Here you can find the source of XMLFileToString(String xmlname, Context context)
public static String XMLFileToString(String xmlname, Context context)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.content.Context; import android.widget.Toast; public class Main { public static String XMLFileToString(String xmlname, Context context) { InputStream XML_Stream = null; try {/* w w w .j a v a 2 s. com*/ XML_Stream = context.getAssets().open(xmlname); } catch (IOException e) { Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } BufferedReader in = new BufferedReader(new InputStreamReader( XML_Stream)); StringBuffer buffer = new StringBuffer(); String line = ""; try { while ((line = in.readLine()) != null) { buffer.append(line); } } catch (IOException e1) { Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG) .show(); e1.printStackTrace(); } return buffer.toString(); } }