解决方法
或
... ORDER BY column COLLATE UNICODE
要么
... ORDER BY column COLLATE LOCALIZED
In addition to sqlite’s default
BINARY
collator,Android supplies two more,LOCALIZED
,which changes with the system’s current locale,andUNICODE
,which is the Unicode Collation Algorithm and not tailored to the current locale.
例:
db.execsql("CREATE TABLE foo(a TEXT);"); db.execsql("INSERT INTO foo VALUES('Antonio'),('Bonzo'),('Zeto'),('Ángela');"); Cursor c = db.rawQuery("SELECT * FROM foo ORDER BY a COLLATE UNICODE",null); while (c.moveToNext()) { Log.d("foo",c.getString(0)); }
输出:
Ángela Antonio Bonzo Zeto