3

All I am trying to do is to get the text from the Edittext which is having the features like bold and italic and saving it in a text file but when I read it back and display it, the features are lost, they don't show. How can I maintain the rich features by saving the text in a text file or any.

class Android
  • 762
  • 1
  • 6
  • 17

1 Answers1

1

You can use Html.toHtml() to convert the Editable that you get back from getText() on an EditText to an HTML representation. Then, later on, you can use Html.fromHtml() to convert the HTML back into something that can be used in an EditText. toHtml() and fromHtml() do not handle every possible span used by EditText, but it should handle the basics like bold and italics.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491