1

I'm trying to save the text from an EditText, I got it working, but I don't think I'm doing it correctly. When I reopen it in my app it's fine, but when I pull it from the device and I open it in windows notepad I lose the line-breaks.

...     
        try {
            BufferedWriter buf = new BufferedWriter(new FileWriter(file, true));
            buf.append(cv.getText().toString());
            buf.close();
        } catch(IOException e) {
            e.printStackTrace();
        }

What's the correct way to save large EditText's full of text?

bwoogie
  • 4,339
  • 12
  • 39
  • 72

2 Answers2

5

You're doing the right thing - the problem is that Notepad doesn't understand Unix line termination conventions.

Open the file in Wordpad, and you'll see it should be displayed correctly.

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
2

Try buf.append(cv.getText().toString().replace("\n", "\r\n"); to make the linebreaks readable in Windows programs.

koopaking3
  • 3,375
  • 2
  • 25
  • 36