Home | History | Annotate | Download | only in provider

Lines Matching defs:db

34  * Utility class to update DB schema after it has been restored.
55 SQLiteDatabase db = helper.getWritableDatabase();
56 db.beginTransaction();
58 new RestoreDbTask().sanitizeDB(helper, db);
59 db.setTransactionSuccessful();
62 FileLog.e(TAG, "Failed to verify db", e);
65 db.endTransaction();
70 * Makes the following changes in the provider DB.
78 private void sanitizeDB(DatabaseHelper helper, SQLiteDatabase db) throws Exception {
79 long oldProfileId = getDefaultProfileId(db);
81 int itemsDeleted = db.delete(
92 db.update(Favorites.TABLE_NAME, values, null, null);
99 db.update(Favorites.TABLE_NAME, values, "itemType = ?",
105 migrateProfileId(db, myProfileId);
112 protected void migrateProfileId(SQLiteDatabase db, long newProfileId) {
116 db.update(Favorites.TABLE_NAME, values, null, null);
119 db.execSQL("ALTER TABLE favorites RENAME TO favorites_old;");
120 Favorites.addTableToDb(db, newProfileId, false);
121 db.execSQL("INSERT INTO favorites SELECT * FROM favorites_old;");
122 db.execSQL("DROP TABLE favorites_old;");
126 * Returns the profile id used in the favorites table of the provided db.
128 protected long getDefaultProfileId(SQLiteDatabase db) throws Exception {
129 try (Cursor c = db.rawQuery("PRAGMA table_info (favorites)", null)){