I am trying to write to a simple text file on the Android system. This is my code:
public void writeClassName() throws IOException{
String FILENAME = \"c
Try to use the approach from this article in developer guide:
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
Because you are trying to write the file to root, you need to pass the file path to your file directory.
Example
String filePath = context.getFilesDir().getPath().toString() + "/fileName.txt";
File f = new File(filePath);