Here you can find the source of readFromFile(Context context, String fileName)
public static String readFromFile(Context context, String fileName)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import android.content.Context; public class Main { public static String readFromFile(Context context, String fileName) { InputStream is = null;//from w w w.ja v a2 s. co m StringBuilder sb = new StringBuilder(); // String temp = null; File file; if (fileName == null || fileName.equals("")) { return null; } try { file = context.getFileStreamPath(fileName); is = new FileInputStream(file); InputStreamReader isr = new InputStreamReader(is, "UTF-8"); int c; char[] charStr = new char[1024]; while ((c = isr.read(charStr)) != -1) { sb.append(charStr, 0, c); } is.close(); } catch (Exception e) { e.printStackTrace(); return null; } return sb.toString(); } }