Reputation: 4427
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?
Upvotes: 1
Views: 202
Reputation: 3433
Try buf.append(cv.getText().toString().replace("\n", "\r\n");
to make the linebreaks readable in Windows programs.
Upvotes: 2
Reputation: 5961
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.
Upvotes: 5