To write to a file:
try { File myFile = new File(Environment.getExternalStorageDirectory().getPath()+"/textfile.txt"); myFile.createNewFile(); FileOutputStream fOut = new FileOutputStream(myFile); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.write("replace this with your string"); myOutWriter.close(); fOut.close(); } catch (Exception e) { e.printStackTrace(); }
To read from a file:
String pathoffile; String contents=""; File myFile = new File(Environment.getExternalStorageDirectory().getPath()+"/textfile.txt"); if(!myFile.exists()) return ""; try { BufferedReader br = new BufferedReader(new FileReader(myFile)); int c; while ((c = br.read()) != -1) { contents=contents+(char)c; } } catch (IOException e) {
Thus, you will return the contents of your file in the "Content" line
Note: you must provide read and write permissions in the manifest file
source share