Possible Duplicate:
Android write to sd card folder
Writing a File with this Code:
public void writeFile(String data){
try { // catches IOException below
final String TESTSTRING = new String(data+"-");
String path=Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/test.txt";
FileOutputStream fOut = openFileOutput(path,
MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file
osw.write(TESTSTRING);
/* ensure that everything is
* really written out and close */
osw.flush();
osw.close();
}catch (Exception e) {
e.printStackTrace();
}
}
Error Generated by Above Code:
java.lang.IllegalArgumentException: File /sdcard/test.txt contains a path separator
I couldn't find what's wrong with this code.