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.
Asked
Active
Viewed 486 times
3
-
you need to get EditText text as HTML ... – Selvin Dec 05 '12 at 15:47
1 Answers
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
-
Is there any file format that could save the text as it is in EditText as a text file doesn't support it. – class Android Jan 25 '13 at 12:09
-
1@user1878746: Text files definitely support HTML. The Web page that you are viewing is text. – CommonsWare Jan 25 '13 at 13:50