title: How to append data to a text file in Android?
body: <p>I want to store some data in a file. The content of the file will keep increasing so I need to append data to that file.</p>
  
  <p>FileOperation.java</p>
  
  <pre><code>package com.chinmay.callblocker;
  
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.OutputStreamWriter;
  
  /**
   * Created by user on 11/11/2014.
  */
  public class FileOperation {
  
  public Boolean write(String file_name, String content) {
      try {
          String file_path = "/sdcard/"+file_name+".txt";
          File file = new File(file_path);
  
          if(!file.exists()) {
              file.createNewFile();
          }
  
          FileWriter fw = new FileWriter(file.getAbsoluteFile());
          BufferedWriter bw = new BufferedWriter(fw);
  
          /*FileOutputStream fos = new FileOutputStream(file);
          OutputStreamWriter osw = new OutputStreamWriter(fos);
  
          osw.append(content);
          osw.close();
          fos.close();*/
  
          bw.append(content);
          bw.append("\n");
          bw.close();
  
          return true;
      } catch(IOException e) {
  
          e.printStackTrace();
          return false;
      }
  }
  }
  </code></pre>
  
  <p>I am using append on file but still it only overwrites.</p>