New with Android. Sorry! I'm trying to create the following...
The code for writing to the file is as follows...
File file = new File("/sdcard/log.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(str);
writer.newLine();
writer.flush();
writer.close();
The code is only writing the last .write in the file! The previous WRITE is removed. I suspect that its creating a new file everytime and writing the latest line. I tried with FOS and OSW but with same results! Please help, am stuck on this one for almost 48 hours.
Use the FileWriter
in append mode.
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));