Add indexing for SwitchPreferences

- now support the SwitchPreferences and save the "switchOn" and "switchOff"
attributes
- update Index database schema (and increment its version)
- fix an issue with some previous schema not rebuilt

Change-Id: I9cd48c666525f19474ef9bd5746d61b589058063
This commit is contained in:
Fabrice Di Meglio
2014-04-02 19:37:39 -07:00
parent a41707200b
commit dd41dfc483
3 changed files with 105 additions and 31 deletions

View File

@@ -28,7 +28,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "IndexDatabaseHelper";
private static final String DATABASE_NAME = "search_index.db";
private static final int DATABASE_VERSION = 105;
private static final int DATABASE_VERSION = 106;
public interface Tables {
public static final String TABLE_PREFS_INDEX = "prefs_index";
@@ -46,6 +46,10 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
public static final String DATA_SUMMARY_OFF = "data_summary_off";
public static final String DATA_SUMMARY_OFF_NORMALIZED = "data_summary_off_normalized";
public static final String DATA_ENTRIES = "data_entries";
public static final String DATA_SWITCH_ON = "data_switch_on";
public static final String DATA_SWITCH_ON_NORMALIZED = "data_switch_on_normalized";
public static final String DATA_SWITCH_OFF = "data_switch_off";
public static final String DATA_SWITCH_OFF_NORMALIZED = "data_switch_off_normalized";
public static final String DATA_KEYWORDS = "data_keywords";
public static final String CLASS_NAME = "class_name";
public static final String SCREEN_TITLE = "screen_title";
@@ -81,6 +85,14 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
", " +
IndexColumns.DATA_ENTRIES +
", " +
IndexColumns.DATA_SWITCH_ON +
", " +
IndexColumns.DATA_SWITCH_ON_NORMALIZED +
", " +
IndexColumns.DATA_SWITCH_OFF +
", " +
IndexColumns.DATA_SWITCH_OFF_NORMALIZED +
", " +
IndexColumns.DATA_KEYWORDS +
", " +
IndexColumns.SCREEN_TITLE +
@@ -153,7 +165,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 100 || oldVersion == 101 || oldVersion == 102 || oldVersion == 103) {
if (oldVersion < DATABASE_VERSION) {
Log.w(TAG, "Detected schema version '" + oldVersion + "'. " +
"Index needs to be rebuilt for schema version '" + newVersion + "'.");
// We need to drop the tables and recreate them