I am using commonsguy / cwac-richedit Library for Rich Text Editing. After doing so i am saving the formatted text in the database. But when i retrieve the saved formatted string its formatting is removed.
I want to know that how to save/retrieve the text from the database without losing format.
EditText
uses HTML markup (limited set). Key Interfaces for this type of markup text being Spanned
and Spannable
.
EditText
uses Editable
to represent text, which implements Spannable
.
Html
class is provided for conversions between markup and Spanned text, you can use it as well:
//--suppose this is typed to an EditText called et --
Spanned s = Html.fromHtml("<i>Hi</i> There ! <b>how're you ?</b>");
et.setText(s);
//--save to string--
Editable e = et.getText();
String s2 = Html.toHtml(e);
//--restore from string--
Spanned s3 = Html.fromHtml(s2);
et.setText(s3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With