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
  • 28,539
  • 63
  • 155
  • 235
  • 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
  • 13,436
  • 25
  • 87
  • 129