user2931692
user2931692

Reputation: 17

how to save encoded html in string

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?????????????

Upvotes: 0

Views: 778

Answers (2)

Dinesh Raj
Dinesh Raj

Reputation: 654

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

Upvotes: 0

Devrim
Devrim

Reputation: 15533

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();

Upvotes: 1

Related Questions