Display special characters in android application from sqlite database

I have a Periodic table of elements application for android that stores most of its data in string arrays. Now I am trying to use the sqlite database instead of arrays, but I have a little problem. If I type "android: text =" & # 185; "directly in TextView, it will display superscript 1 (for example, this-> ¹), but if I save '& # 185;' like text in sqlite database, and then use the cursor to fill the same TextView, instead of the displayed superscript 1, I just see "& # 185;" just like I typed it. How can I get the TextView to display special characters when filling sqlite database? I struggled for a while and was at a standstill, so any suggestions would be appreciated. Thanks!

+3
source share
1 answer

Use Java Unicode string notation for each special character when inserting them into your database.
For '¹' it will: \u00b9.

As an alternative to parsing HTML tags and character objects such as ¹in TextView, you can possibly wrap the string in the call Html.fromHtml()before calling setText().

+3
source

Source: https://habr.com/ru/post/1786461/


All Articles