diff options
author | Makoto Onuki <omakoto@google.com> | 2015-06-22 15:42:36 -0700 |
---|---|---|
committer | Makoto Onuki <omakoto@google.com> | 2015-06-22 15:42:36 -0700 |
commit | e090212bd2ff31a8f79a11e1e9b0980f7f6079fe (patch) | |
tree | 44f41eed64ccaeb76bbeccfc43c30f496ef033e7 /src/com/android | |
parent | 71f0747e4126c41aa30a5ffc431b8c70b3458445 (diff) | |
download | packages_providers_ContactsProvider-e090212bd2ff31a8f79a11e1e9b0980f7f6079fe.zip packages_providers_ContactsProvider-e090212bd2ff31a8f79a11e1e9b0980f7f6079fe.tar.gz packages_providers_ContactsProvider-e090212bd2ff31a8f79a11e1e9b0980f7f6079fe.tar.bz2 |
Always atomically drop & create search index.
There was a chance the process or the device getting crashed right after the
DROP.
Bug 21925160
Change-Id: I25bfac0d8994644cc3ca39851f5cfcea6f541f37
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/providers/contacts/ContactsDatabaseHelper.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java index fc81fa5..aac37ba 100644 --- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java +++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java @@ -1646,16 +1646,22 @@ public class ContactsDatabaseHelper extends SQLiteOpenHelper { } public void createSearchIndexTable(SQLiteDatabase db, boolean rebuildSqliteStats) { - db.execSQL("DROP TABLE IF EXISTS " + Tables.SEARCH_INDEX); - db.execSQL("CREATE VIRTUAL TABLE " + Tables.SEARCH_INDEX - + " USING FTS4 (" + db.beginTransaction(); + try { + db.execSQL("DROP TABLE IF EXISTS " + Tables.SEARCH_INDEX); + db.execSQL("CREATE VIRTUAL TABLE " + Tables.SEARCH_INDEX + + " USING FTS4 (" + SearchIndexColumns.CONTACT_ID + " INTEGER REFERENCES contacts(_id) NOT NULL," + SearchIndexColumns.CONTENT + " TEXT, " + SearchIndexColumns.NAME + " TEXT, " + SearchIndexColumns.TOKENS + " TEXT" - + ")"); - if (rebuildSqliteStats) { - updateSqliteStats(db); + + ")"); + if (rebuildSqliteStats) { + updateSqliteStats(db); + } + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); } } |