Added option to enable sqlite unicode61 tokenizer

This commit is contained in:
M66B
2022-09-29 12:07:33 +02:00
parent 28832bcbf2
commit 3811afe451
5 changed files with 58 additions and 7 deletions

View File

@@ -56,8 +56,9 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
}
static SQLiteDatabase getInstance(Context context) {
if (instance == null) {
if (!context.getDatabasePath(DATABASE_NAME).exists()) {
boolean exists = context.getDatabasePath(DATABASE_NAME).exists();
if (instance == null || !exists) {
if (!exists) {
Fts5DbHelper.delete(context);
DB.getInstance(context).message().resetFts();
}
@@ -73,8 +74,8 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
// https://www.sqlite.org/fts3.html#tokenizer
// https://unicode.org/reports/tr29/
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean unicode61 = prefs.getBoolean("unicode61", BuildConfig.DEBUG);
String tokenizer = (unicode61 ? "tokenize=unicode61 \"remove_diacritics=0\"" : null);
boolean unicode61 = prefs.getBoolean("sqlite_unicode61", false);
String tokenizer = (unicode61 ? "tokenize=unicode61 \"remove_diacritics=2\"" : null);
db.execSQL("CREATE VIRTUAL TABLE `message`" +
" USING fts4" +