SQLiteDatabase - How to use where clause?

前端 未结 7 764
情歌与酒
情歌与酒 2021-02-09 02:57
public Cursor fetchTimetable() {
    return mDb.query(DATABASE_TABLE_TIMETABLE, new String[] {TIMETABLE_ROWID,    TIMETABLE_MODULECODE, TIMETABLE_MODULENAME, TIMETABLE_R         


        
7条回答
  •  深忆病人
    2021-02-09 03:22

    My working example with where args (it's more clear with using it):

            String [] settingsProjection = {
                    DBContract.Settings._ID,
                    DBContract.Settings.COLUMN_NAME_USER_ID,
                    DBContract.Settings.COLUMN_NAME_AUTO_LOGIN
            };
    
            String whereClause = DBContract.Settings.COLUMN_NAME_USER_ID+"=?";
            String [] whereArgs = {userId.toString()};
    
            Cursor c = db.query(
                    DBContract.Settings.TABLE_NAME,
                    settingsProjection,
                    whereClause,
                    whereArgs,
                    null,
                    null,
                    null
            );
    

提交回复
热议问题