1public static boolean saveToInternalStorage(String data, String filename, Context context) throws IOException {
2 FileOutputStream fos = context.openFileOutput(filename, Context.MODE_PRIVATE);
3 //default mode is PRIVATE, can be APPEND etc.
4 fos.write(data.getBytes());
5 fos.close();
6 return true;
7}
8
9public static String readFileFromInternalStorage(String filename, Context context) throws IOException {
10 FileInputStream fis = context.openFileInput(filename);
11 InputStreamReader isr = new InputStreamReader(fis);
12 BufferedReader bufferedReader = new BufferedReader(isr);
13 StringBuilder sb = new StringBuilder();
14 String line;
15 while ((line = bufferedReader.readLine()) != null) {
16 sb.append(line);
17 }
18 bufferedReader.close();
19 return sb.toString();
20}