emojicon icon indicating copy to clipboard operation
emojicon copied to clipboard

How to store these emoji's to SQLite database and retrieve them?

Open curiousmit opened this issue 10 years ago • 20 comments

Problem storing these emoji's to SQLite database and retrieving them as these emoji's support utf8mb4 encoding which is not supported by SQLite, i suppose. Currently if i try to store and retrieve from database it gives a ?? for each emoji.

How to store and retrieve these to android SQLite database.

curiousmit avatar Jul 05 '14 06:07 curiousmit

What about encoding the codepoints to base64 or something?

daniele-athome avatar Aug 17 '14 19:08 daniele-athome

Not working by encoding them to Base64...any other alternative? On Aug 18, 2014 1:25 AM, "Daniele Ricci" [email protected] wrote:

What about encoding the codepoints to base64 or something?

— Reply to this email directly or view it on GitHub https://github.com/rockerhieu/emojicon/issues/12#issuecomment-52432833.

curiousmit avatar Sep 26 '14 13:09 curiousmit

I'm currently storing them on a database for my messages without any hassle and even without base64. On Android you don't even need to set an encoding, it's UTF-8 by default.

daniele-athome avatar Sep 27 '14 14:09 daniele-athome

You are absolutely right about the default encoding scheme in android but the emojicon library emoji's are of utf8mb4 encoding scheme i suppose, which is not supported by Sqlite. Moreover i tried storing them without encoding, i didnt find any problem regarding storing, but while retrieving them from database and setting them to any view it shows me ?? for each emoji. Any idea about the problem? On Sep 27, 2014 7:57 PM, "Daniele Ricci" [email protected] wrote:

I'm currently storing them on a database for my messages without any hassle and even without base64. On Android you don't even need to set an encoding, it's UTF-8 by default.

— Reply to this email directly or view it on GitHub https://github.com/rockerhieu/emojicon/issues/12#issuecomment-57054278.

curiousmit avatar Sep 27 '14 14:09 curiousmit

I guess you are using an EmojiconTextView to display them?

daniele-athome avatar Oct 01 '14 06:10 daniele-athome

Yep, indeed am using emojicon textview to display after retrieving them from db. On Oct 1, 2014 12:14 PM, "Daniele Ricci" [email protected] wrote:

I guess you are using an EmojiconTextView to display them?

— Reply to this email directly or view it on GitHub https://github.com/rockerhieu/emojicon/issues/12#issuecomment-57425107.

curiousmit avatar Oct 01 '14 06:10 curiousmit

I don't know what could be wrong... can you show us the code that stores and retrieves the data and displays it?

daniele-athome avatar Oct 01 '14 06:10 daniele-athome

Well i'll try to make a demo and show it to you. Basically, according to what i understand, the problem might b the encoding scheme while storing the data.

I will explain you the scenario taking place in my case. I have made a web service, where the data that i entered is stored (data includes text as well as emoji) and as soon as i click on a button the data is passed on the api as string and stored to web db and the data that i sent which inckuded text and emoji will be returned from web db as response in json format, which i parse and store it in SQLite db in android and then i fetch it from db and set it to a emojicon textview. On Oct 1, 2014 12:18 PM, "Daniele Ricci" [email protected] wrote:

I don't know what could be wrong... can you show us the code that stores and retrieves the data and displays it?

— Reply to this email directly or view it on GitHub https://github.com/rockerhieu/emojicon/issues/12#issuecomment-57425372.

curiousmit avatar Oct 01 '14 07:10 curiousmit

Oh I see now: the data does not go directly into SQLite and come back from it. It goes through a server and a server-side database, isn't it? You should check the encoding then you're probably right. But I think you loose the encoding in the server processing somehow.

daniele-athome avatar Oct 01 '14 07:10 daniele-athome

I have the same problem.

Does Anyone got any solution ?

I need to save message from EmojiconEditText to database and after get data and show in a EmojiconTextView.

Is it possible ?

gorio avatar Sep 04 '15 16:09 gorio

Yes indeed i have found one. The data type for the emoji to be stored on server, needs to be kept as NVARCHAR or equivalent. For me, that solved the problem of storing and retrieving emoji to and from db. On 4 Sep 2015 21:39, "Eduardo Gorio" [email protected] wrote:

I have the same problem.

Does Anyone got any solution ?

I need to save message from EmojiconEditText to database and after get data and show in a EmojiconTextView.

Is it possible ?

— Reply to this email directly or view it on GitHub https://github.com/rockerhieu/emojicon/issues/12#issuecomment-137778798.

curiousmit avatar Sep 04 '15 16:09 curiousmit

Have you used SQLite ?

gorio avatar Sep 04 '15 17:09 gorio

How to get text from EmojiconEditText ?

EmojiconEditText etMessage; etMessage.getText().toString()

gorio avatar Sep 04 '15 17:09 gorio

@themitshah could you contact me [email protected] ? Thank you

gorio avatar Sep 04 '15 17:09 gorio

screenshot_2015-09-04-15-31-52

gorio avatar Sep 04 '15 18:09 gorio

you may store the emoticons from edit text as StringEscapeUtils.escapeJava(edittext.getText().toString()); to get it in unicode format.

and decode it back to emoticon u can use textview.setText(StringEscapeUtils.unescapeJava(<unicode_emoticon>));

seema7 avatar Sep 05 '15 06:09 seema7

i through "rails new scaffold p name :string description:text" and i use the sqlite,when the description has emoji, the sqlite can not store it ,how to deal it?thanks

Wumingla avatar Dec 21 '15 09:12 Wumingla

I don't know if this is applicable to SQLite, but I just get the String from the EditText (EmojiconEditText.getText().toString()), and then de/encode the string as described here. Works fine for MySQL

AljoSt avatar Jul 11 '16 14:07 AljoSt

You can save the emoticons into Sqlite db by saving the emoticon's emoji i.e use StringEscapeUtils.escapeJava(EmojiconEditText.getText().toString()); to get the uniocode of the emoji and save it to Sqlite. To retrieve back the emoticon from that unicode use StringEscapeUtils.unescapeJava(<unicode_emoticon>); and set the value received from above to a textview which displays the required emoticon ..

seema7 avatar Jul 13 '16 05:07 seema7

Yes indeed i have found one. The data type for the emoji to be stored on server, needs to be kept as NVARCHAR or equivalent. For me, that solved the problem of storing and retrieving emoji to and from db. On 4 Sep 2015 21:39, "Eduardo Gorio" [email protected] wrote:

I have the same problem. Does Anyone got any solution ? I need to save message from EmojiconEditText to database and after get data and show in a EmojiconTextView. Is it possible ? — Reply to this email directly or view it on GitHub #12 (comment).

can you post your 'create table sql'

szuwest avatar Nov 17 '21 03:11 szuwest