I have a problem when executing select query in android with sqlite database. In database there is a field based on sinhala characters. I populate the database using DB browser in UTF-8 encoding. I used SQLiteAssetHelper to access database in assets folder. when i try to use select query and display in android textview the data in field based on sinhala outputs strange characters like විද්â€.
I try to change the font in textview and try to change the encoding by using System.setProperty( sinhala_word,"UTF-8" ).
As example when try to set word
රහිත
in android text view it shows like
රහිà¶
this is how my database looks like:
This is how text appears in text view:
Related
Wrote a markdown text using https://stackedit.io, copied the markdown output, and pasted it into a Firestore field to be rendered in my android app using the markwon library.
However, I noticed that the text from Firestore did not render properly on the android but the raw markdown text when used directly on the app rendered well. After investigation, discovered that Firestore stripes all the new line in the markdown text and only displays a large text without new line or line break.
What I have tried:
I have tried to replace \\n character with \n before rendering - Did not work
Manually add \n character in the firestore text - Did not work
Converted the markdown to html before storing in firestore - Worked but not sustainable and didn't give desired output
How do I fix this ssue such that the markdown text in firestore is rendered correctly on android?
Firestore does not support escape sequences in string values. It simply does not understand any sort of escape sequences that might have a special meaning in a particular programming language.
This means that if you write "\n" in a string-type field, and later when you want to read it, you'll read exactly that backslash and the n character. If you need to store special escape sequences like \n or \\n, then you consider encoding and decoding that yourself.
I have a appData.db file which I collected form .apk file.
Now when I open this file into 'DB Browser for SQLite', some fields are not showing properly. It contains bangle text.
This field working good
This field is not working, this is actually bangla text
I am making a note application and want the user to be able to edit in rich text.
The user writes the note, then it gets converted into html and saved into a database.
This way when it is retrieved from the database, it does not lose its rich text.
Yet I am having a problem, if the user adds a color to their text and saves the note it converts it to html like this
"<p><font color=#0000ff>user text</font></p>"
when retrieved from the database no text color shows up. this is because android saves the html wrong. In order for android to get color from html the letters need to be capitalized like this
"<p><font color=#0000FF>user text</font></p>"
This confuses me because if android can only read it in caos why doesn't it convert it in that way.
How do I get it so when this code runs
//--save to string--//
Editable e = noteContent.getText();
String s2 = Html.toHtml(e);
Spanned s3 = Html.fromHtml(s2);
classes.setText(s3);
to save the text color to the caps. so when it is retrieved form the database the text color shows up.
Thanks,
Jordan
Make sure your RGB value is CAPITALIZED.
Try to use:
Html.fromHtml("<![CDATA[<font color='#145A14'>text</font>]]>");
Hope this help!
I am trying to create a database for an android app including, in part, non-English words which require underlines and accents for proper spelling. I set my encoding for this package to utf-8, which allowed the accented characters to store and display properly. However, I cannot seem to get a single character underlined. It displays an empty box for an unrecognized character.
An example of my database helper to create the sqlite is as follows:
cv.put(ENGLISH, "to be alive");
cv.put(NATIVE, "okch_á_a or okchaha");
cv.put(PART_OF_SPEECH, "verb");
cv.put(AUDIO, "alive");
cv.put(VIDEO, "none");
cv.put(IMAGE_DEFAULT, "none");
cv.put(IMAGE_OPTIONAL, "none");
cv.put(IMAGE_TO_USE, "none");
db.insert("words", ENGLISH, cv);
That
_ a _
is the best I can come up with so far, but the a should actually be an underlined character.
I tried html tags like u and /u:
<u>a</u>
since that works with string arrays, but it displays as:
<u>a</u>
(the html is never interpreted).
I tried using:
"\u0332"
as explained at http://www.fileformat.info/info/unicode/char/332/index.htm , but that, too, is never interpreted, so it displays as:
a\u0332
I also tried:
& # 818 ;
and:
& # x332 ;
in a similar manner, with similar lack of results.
Any ideas?
You can store your string in Html format and call .setText(Html.fromHtml(somestring)) from the textview were you want to display it.
I have a Periodic table of elements app for android that stores most of it's data in string arrays. I am now trying to use an sqlite database instead of the arrays but am having a small problem. If I type 'android:text="¹"' directly into a TextView it will display a superscript 1(like this-> ¹), but if I store '¹' as text in a sqlite database and then use a cursor to populate that same TextView, instead of the superscript 1 being displayed I just see "¹" exactly as I typed it. How can I get the TextView to display special characters when being populated by a sqlite database? I have been struggling for a while and am stumped so any suggestions would be appreciated. Thanks!
Use the Java Unicode string notation for each special character when inserting them into your database.
For '¹', that would be: \u00b9.
Alternatively, to parse HTML tags and character entities like ¹ in a TextView, then you can probably wrap the String in a call to Html.fromHtml() before calling setText().