title: How To Append In The .txt File And Overwriting In Text File
body: <p>I Am Trying To Save The Incoming Message In .Txt File Sms Is Saving But When The New Sms Come It Is Not Getting Updated Old Sms Is Get Deleted And New Sms Is Shown.
  Plz Tell That How To Overwrite In Existing Text File Which Is Generated In This Code.</p>
  
  <pre><code>if (Environment.MEDIA_MOUNTED.equals(state)) {
                File Root = Environment.getExternalStorageDirectory();
                File Dir = new File(Root.getAbsolutePath() + "/FLOW DATA");
  
      if (!Dir.exists()) {
                 Dir.mkdir();
        }
                File file = new File(Dir`enter code here`, "FLOW DATA.txt");
                          try {
                          FileOutputStream fileOutputStream = new FileOutputStream(file);
                          fileOutputStream.write(message.getBytes());
                          fileOutputStream.close();
  
                          Toast.makeText(context, "Message Saved", Toast.LENGTH_LONG).show();
                      } 
                      catch (FileNotFoundException e) {
                          e.printStackTrace();
                      }
                      catch (IOException e) {
                          e.printStackTrace();
                      }
  
                  } else {                    
                      Toast.makeText(context, "SD CARD NOT FOUND", Toast.LENGTH_LONG).show();
                  }
  
      }
  </code></pre>