Skip to content

How can I configure sqflite locale? Or how can I sort results by Chinese character? #942

Answered by alextekartik
Aoi-hosizora asked this question in Q&A
Discussion options

You must be logged in to vote

@Aoi-hosizora I have publish sqflite 2.2.5-0 that suppors calling setLocale.

Let me know if that works for you.

setLocale on Android

Android has a specific setLocale API that allows sorting localized field according to a locale using query like:

SELECT * FROM Test ORDER BY name COLLATE LOCALIZED ASC

There is an extra Android only API to specify the locale to use:

await database.setLocale('fr-FR');

This API must be called during onConfigure (each time you open the database). The specified IETF BCP 47 language tag
string (en-US, zh-CN, fr-FR, zh-Hant-TW, ...) must be as defined in
Locale.forLanguageTag in Android/Java documentation.

var db = await openDatabase(path,
            onConfigure:

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@Aoi-hosizora
Comment options

Comment options

You must be logged in to vote
1 reply
@Aoi-hosizora
Comment options

Comment options

You must be logged in to vote
2 replies
@Aoi-hosizora
Comment options

@alextekartik
Comment options

Answer selected by Aoi-hosizora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants