Here you can find the source of getStringFromResource(int resource, Context context)
public static String getStringFromResource(int resource, 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; public class Main { public static String getStringFromResource(int resource, Context context) { InputStream is = context.getResources().openRawResource(resource); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String readLine = null;/*from w ww. j av a 2 s .com*/ String contents = ""; try { // While the BufferedReader readLine is not null while ((readLine = br.readLine()) != null) { contents += readLine + "\n"; } // Close the InputStream and BufferedReader is.close(); br.close(); } catch (IOException e) { e.printStackTrace(); } return contents; } }