0

How to save encoded value of html to string help me I'm saving html in string htmldescription but is encoded into show actual html see my this post html code change when get in json and save in string

Html code wil change when I save in textview with this command is show perfectly

mytext= (Html.fromHtml(htmldescription));

But I want to save in string what will i do? How to save encoded html(string) in string any idea???

String  htmldescription = school2.getJSONObject(0).getString("description");
mytext= (Html.fromHtml(htmldescription));
String coverthtml= mytext?????????????
Community
  • 1
  • 1
user2931692
  • 17
  • 2
  • 8

2 Answers2

1

This is the original html value:

String  htmldescription = school2.getJSONObject(0).getString("description");

And this is the html formatted value:

Spanned spanned = Html.fromHtml(formattedText);

And this is the String conversion:

String formattedText = spanned.toString();
Devrim
  • 15,345
  • 4
  • 66
  • 74
0

Use Spanned first

Spanned mytext = Html.fromHtml(htmldescription);

now convert the spanned to string

String url=mytext.toString();

To know more details about spanned refer this url

Android Spanned, SpannedString, Spannable, SpannableString and CharSequence

Community
  • 1
  • 1
Dinesh Raj
  • 664
  • 12
  • 30