我正在开发使用SQLite作为后端的Android应用程序。
I am developing an Android application using SQLite as backend.
我要确保所有数据库中的表使用UTF-8。我怎样才能做到这一点?
I want to make sure all the tables in the database use UTF-8. How can I achieve that?
我曾尝试:
CREATE TABLE myTable (_all_columns_definitions_) DEFAULT CHARSET=utf8;
但语法错误出现。
but a syntax error arose.
由于sqlite的只支持UTF-8和UTF-16的编码,你会发现Android是否会比UTF-8以外的其他创建数据库。 sqlite3_open 默认创建的UTF-8的数据库,而这正是Android是可能使用。
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.