Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding new lines of text in a text file
    primarykey
    data
    text
    <p>My app records sounds. Once the sound is recorded, user is asked to input a new file name. Now what I'm trying to do next is to add all file names in a text file so that I can read it later as an array to make a listview.</p> <p>This is the code:</p> <pre><code>//this is in onCreate File recordedFiles = new File(externalStoragePath + File.separator + "/Android/data/com.whizzappseasyvoicenotepad/recorded files.txt"); if(!recordedFiles.exists()) { try { recordedFiles.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } //this executes everytime text is entered and the button is clicked try { String content = input.getText().toString(); FileWriter fw = new FileWriter(recordedFiles.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write("&gt;" + content + ".mp3"); bw.close(); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p>Now the problem is that everytime I record a new file, the previous line is overwritten. So if I record two files 'text1' and 'text2', after I've recorded text1, the txt file will show text1, but after I recorded the text2, the text2 will overwrite the text1 instead of inserting a new line.</p> <p>I tried adding:</p> <pre><code>bw.NewLine() </code></pre> <p>before</p> <pre><code>bw.write("&gt;" + content + ".mp3"); </code></pre> <p>but it doesn't work.</p> <p>If I record three sounds and name them sound1, sound2 and sound3, I want this to be the result:</p> <pre><code>&gt;sound1 &gt;sound2 &gt;sound3 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload