Use Html.toHtml()
to convert a Spanned
back into HTML, then save the resulting HTML string in your SharedPreferences
.
Note, though, that not everything supported by fromHtml()
is also supported by toHtml()
(and vice versa).
Question
I have a ListView with Spanned items. As this concept:
Spanned Test = Html.fromHtml(getString(R.string.teststring));
is very slow I would like to save these Spanned in SharedPreferences. The problem is that I can only save strings and lose the entire html formatting. Any idea how to solve this problem?
Solution
Use Html.toHtml()
to convert a Spanned
back into HTML, then save the resulting HTML string in your SharedPreferences
.
Note, though, that not everything supported by fromHtml()
is also supported by toHtml()
(and vice versa).