I am working on an Android app and I would like to write into a text file. But after clicking the write button, the app shows me an error message and stops. The error is
IllegalArgumentException: File mnt/sdcard/test.txt contains a path separator
I have used the following code:
try {
final String TESTSTRING = new String("Hello Android");
FileOutputStream fOut = openFileOutput("mnt/sdcard/test.txt",
MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(TESTSTRING);
osw.flush();
osw.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}