Android examples for android.content.res:Resources
Read Resources to string
import android.content.res.Resources; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; public class Main{ public static boolean appendRes(StringBuilder sb, Resources res, int resId) { Reader reader = null;// www .j av a2s .co m try { InputStream inputStream = res.openRawResource(resId); reader = new InputStreamReader(inputStream, "UTF-8"); char[] buffer = new char[inputStream.available()]; reader.read(buffer); sb.append(buffer); } catch (IOException e) { return false; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { } } } return true; } }