title: How to add a line in a text file without overwriting it (JAVA)?
body: <p>My data is stored in an ArrayList whose size increases during program execution.
  I managed to save all the data whenever the size increases, but this brings me to overwrite the data already stored.
  The solution is to go directly to the bottom line and insert the contents of the last cell of ArrayList. Unfortunately I do not know how to implement it.
  Thank you for helping me to do this.</p>
  
  <p>Below is the method I used.</p>
  
  <pre><code>private void SaveLocationData(){
      try {
  
          FileOutputStream output = openFileOutput("latlngpoints.txt",Context.MODE_PRIVATE);
          DataOutputStream dout = new DataOutputStream(output);                     
          dout.writeInt(LocationList.size()); 
          for (Location location : LocationList) {
              dout.writeUTF(location.getLatitude() + "," + location.getLongitude());              
          }
          dout.flush(); // Flush stream ...
          dout.close(); // ... and close.
      } catch (IOException exc) {
          exc.printStackTrace();
      }   
  }
  </code></pre>