10
FileWriter f;
try {
 f = new FileWriter(Environment.getExternalStorageDirectory()+
                 "/Text/o1"+".txt");
     f.write("Hello World");
 f.flush();
 f.close();
}

I can create a file and write to it using the above code. How do i append to the text file without over writing it? thanks

Beginner
  • 27,041
  • 62
  • 151
  • 234
  • 1
    Use FileWriter : [http://developer.android.com/reference/java/io/FileWriter.html](http://developer.android.com/reference/java/io/FileWriter.html) – Farzin Zaker Apr 15 '11 at 15:24

1 Answers1

37

Use FileWriter(File file,boolean append) constructor while creating FileWriter.

Umesh K
  • 12,846
  • 22
  • 85
  • 126