Make sure the SQLite on Android uses UTF-8 as a charset

后端 未结 3 1969
太阳男子
太阳男子 2020-12-09 10:48

I am developing an Android application using SQLite as backend.

I want to make sure all the tables in the database use UTF-8. How can I achieve that?

I have

相关标签:
3条回答
  • 2020-12-09 11:10

    Given that sqlite only supports UTF-8 and UTF-16 as the encodings, you would have noticed if Android would create databases in something other than UTF-8. sqlite3_open defaults to create the database in UTF-8, and that is what Android is likely to use.

    0 讨论(0)
  • 2020-12-09 11:15

    You need to make use of the encoding PRAGMA:

    PRAGMA encoding = "UTF-8";
    
    0 讨论(0)
  • By default Android SQLite uses UTF-8. I had the same problem with special characters, but because when I populated the database on the first launch I used a txt file with another charset.

    0 讨论(0)
提交回复
热议问题