Lines Matching refs:db
133 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in query() local
134 Cursor result = qb.query(db, projection, args.where, args.args, null, null, sortOrder); in query()
141 SQLiteDatabase db, String table, String nullColumnHack, ContentValues values) { in dbInsertAndCheck() argument
149 return db.insert(table, nullColumnHack, values); in dbInsertAndCheck()
172 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in insert() local
174 final long rowId = dbInsertAndCheck(mOpenHelper, db, args.table, null, initialValues); in insert()
202 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in bulkInsert() local
203 db.beginTransaction(); in bulkInsert()
208 if (dbInsertAndCheck(mOpenHelper, db, args.table, null, values[i]) < 0) { in bulkInsert()
212 db.setTransactionSuccessful(); in bulkInsert()
214 db.endTransaction(); in bulkInsert()
225 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in applyBatch() local
226 db.beginTransaction(); in applyBatch()
229 db.setTransactionSuccessful(); in applyBatch()
233 db.endTransaction(); in applyBatch()
241 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in delete() local
242 int count = db.delete(args.table, args.where, args.args); in delete()
254 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in update() local
255 int count = db.update(args.table, values, args.where, args.args); in update()
304 SQLiteDatabase db = mOpenHelper.getWritableDatabase(); in deleteEmptyFolders() local
305 db.beginTransaction(); in deleteEmptyFolders()
313 Cursor c = db.query(TABLE_FAVORITES, in deleteEmptyFolders()
321 db.delete(TABLE_FAVORITES, Utilities.createDbSelectionQuery( in deleteEmptyFolders()
324 db.setTransactionSuccessful(); in deleteEmptyFolders()
329 db.endTransaction(); in deleteEmptyFolders()
546 public void onCreate(SQLiteDatabase db) { in onCreate() argument
553 addFavoritesTable(db, false); in onCreate()
554 addWorkspacesTable(db, false); in onCreate()
578 mMaxItemId = initializeMaxItemId(db); in onCreate()
599 private void addFavoritesTable(SQLiteDatabase db, boolean optional) { in addFavoritesTable() argument
601 db.execSQL("CREATE TABLE " + ifNotExists + TABLE_FAVORITES + " (" + in addFavoritesTable()
629 private void addWorkspacesTable(SQLiteDatabase db, boolean optional) { in addWorkspacesTable() argument
631 db.execSQL("CREATE TABLE " + ifNotExists + TABLE_WORKSPACE_SCREENS + " (" + in addWorkspacesTable()
638 private void removeOrphanedItems(SQLiteDatabase db) { in removeOrphanedItems() argument
649 db.execSQL(removeOrphanedDesktopItems); in removeOrphanedItems()
666 db.execSQL(removeOrphanedFolderItems); in removeOrphanedItems()
674 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { in onUpgrade() argument
683 addWorkspacesTable(db, false); in onUpgrade()
686 db.beginTransaction(); in onUpgrade()
689 db.execSQL("ALTER TABLE favorites " + in onUpgrade()
691 db.setTransactionSuccessful(); in onUpgrade()
697 db.endTransaction(); in onUpgrade()
701 db.beginTransaction(); in onUpgrade()
704 db.execSQL("ALTER TABLE favorites " + in onUpgrade()
706 db.execSQL("ALTER TABLE workspaceScreens " + in onUpgrade()
708 db.setTransactionSuccessful(); in onUpgrade()
714 db.endTransaction(); in onUpgrade()
718 if (!addIntegerColumn(db, Favorites.RESTORED, 0)) { in onUpgrade()
739 removeOrphanedItems(db); in onUpgrade()
743 if (!addProfileColumn(db)) { in onUpgrade()
749 if (!updateFolderItemsRank(db, true)) { in onUpgrade()
754 if (!recreateWorkspaceTable(db)) { in onUpgrade()
758 if (!addIntegerColumn(db, Favorites.OPTIONS, 0)) { in onUpgrade()
768 convertShortcutsToLauncherActivities(db); in onUpgrade()
777 createEmptyDB(db); in onUpgrade()
781 public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { in onDowngrade() argument
785 createEmptyDB(db); in onDowngrade()
791 public void createEmptyDB(SQLiteDatabase db) { in createEmptyDB() argument
792 db.execSQL("DROP TABLE IF EXISTS " + TABLE_FAVORITES); in createEmptyDB()
793 db.execSQL("DROP TABLE IF EXISTS " + TABLE_WORKSPACE_SCREENS); in createEmptyDB()
794 onCreate(db); in createEmptyDB()
801 @Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) { in convertShortcutsToLauncherActivities() argument
802 db.beginTransaction(); in convertShortcutsToLauncherActivities()
810 c = db.query(TABLE_FAVORITES, new String[] { in convertShortcutsToLauncherActivities()
816 updateStmt = db.compileStatement("UPDATE favorites SET itemType=" in convertShortcutsToLauncherActivities()
840 db.setTransactionSuccessful(); in convertShortcutsToLauncherActivities()
844 db.endTransaction(); in convertShortcutsToLauncherActivities()
857 public boolean recreateWorkspaceTable(SQLiteDatabase db) { in recreateWorkspaceTable() argument
858 db.beginTransaction(); in recreateWorkspaceTable()
860 Cursor c = db.query(TABLE_WORKSPACE_SCREENS, in recreateWorkspaceTable()
878 db.execSQL("DROP TABLE IF EXISTS " + TABLE_WORKSPACE_SCREENS); in recreateWorkspaceTable()
879 addWorkspacesTable(db, false); in recreateWorkspaceTable()
888 db.insertOrThrow(TABLE_WORKSPACE_SCREENS, null, values); in recreateWorkspaceTable()
890 db.setTransactionSuccessful(); in recreateWorkspaceTable()
897 db.endTransaction(); in recreateWorkspaceTable()
902 @Thunk boolean updateFolderItemsRank(SQLiteDatabase db, boolean addRankColumn) { in updateFolderItemsRank() argument
903 db.beginTransaction(); in updateFolderItemsRank()
907 db.execSQL("ALTER TABLE favorites ADD COLUMN rank INTEGER NOT NULL DEFAULT 0;"); in updateFolderItemsRank()
911 Cursor c = db.rawQuery("SELECT container, MAX(cellX) FROM favorites" in updateFolderItemsRank()
917 db.execSQL("UPDATE favorites SET rank=cellX+(cellY*?) WHERE " in updateFolderItemsRank()
923 db.setTransactionSuccessful(); in updateFolderItemsRank()
929 db.endTransaction(); in updateFolderItemsRank()
934 private boolean addProfileColumn(SQLiteDatabase db) { in addProfileColumn() argument
940 return addIntegerColumn(db, Favorites.PROFILE_ID, userSerialNumber); in addProfileColumn()
943 private boolean addIntegerColumn(SQLiteDatabase db, String columnName, long defaultValue) { in addIntegerColumn() argument
944 db.beginTransaction(); in addIntegerColumn()
946 db.execSQL("ALTER TABLE favorites ADD COLUMN " in addIntegerColumn()
948 db.setTransactionSuccessful(); in addIntegerColumn()
953 db.endTransaction(); in addIntegerColumn()
973 public long insertAndCheck(SQLiteDatabase db, ContentValues values) { in insertAndCheck() argument
974 return dbInsertAndCheck(this, db, TABLE_FAVORITES, null, values); in insertAndCheck()
986 private long initializeMaxItemId(SQLiteDatabase db) { in initializeMaxItemId() argument
987 return getMaxId(db, TABLE_FAVORITES); in initializeMaxItemId()
1003 private long initializeMaxScreenId(SQLiteDatabase db) { in initializeMaxScreenId() argument
1004 return getMaxId(db, TABLE_WORKSPACE_SCREENS); in initializeMaxScreenId()
1064 SQLiteDatabase db = getWritableDatabase(); in hasScreenId() local
1065 Cursor c = db.rawQuery("SELECT * FROM " + TABLE_WORKSPACE_SCREENS + " WHERE " in hasScreenId()
1077 SQLiteDatabase db = getWritableDatabase(); in getMaxScreenRank() local
1078 Cursor c = db.rawQuery("SELECT MAX(" + LauncherSettings.WorkspaceScreens.SCREEN_RANK in getMaxScreenRank()
1094 @Thunk int loadFavorites(SQLiteDatabase db, AutoInstallsLayout loader) { in loadFavorites() argument
1097 int count = loader.loadLayout(db, screenIds); in loadFavorites()
1107 if (dbInsertAndCheck(this, db, TABLE_WORKSPACE_SCREENS, null, values) < 0) { in loadFavorites()
1115 mMaxItemId = initializeMaxItemId(db); in loadFavorites()
1116 mMaxScreenId = initializeMaxScreenId(db); in loadFavorites()
1121 @Thunk void migrateLauncher2Shortcuts(SQLiteDatabase db, Uri uri) { in migrateLauncher2Shortcuts() argument
1364 db.beginTransaction(); in migrateLauncher2Shortcuts()
1368 if (dbInsertAndCheck(this, db, TABLE_FAVORITES, null, row) in migrateLauncher2Shortcuts()
1375 db.setTransactionSuccessful(); in migrateLauncher2Shortcuts()
1377 db.endTransaction(); in migrateLauncher2Shortcuts()
1381 db.beginTransaction(); in migrateLauncher2Shortcuts()
1387 … if (dbInsertAndCheck(this, db, TABLE_WORKSPACE_SCREENS, null, values) in migrateLauncher2Shortcuts()
1392 db.setTransactionSuccessful(); in migrateLauncher2Shortcuts()
1394 db.endTransaction(); in migrateLauncher2Shortcuts()
1397 updateFolderItemsRank(db, false); in migrateLauncher2Shortcuts()
1411 mMaxItemId = initializeMaxItemId(db); in migrateLauncher2Shortcuts()
1412 mMaxScreenId = initializeMaxScreenId(db); in migrateLauncher2Shortcuts()
1420 @Thunk static long getMaxId(SQLiteDatabase db, String table) { in getMaxId() argument
1421 Cursor c = db.rawQuery("SELECT MAX(_id) FROM " + table, null); in getMaxId()