Android SQLite如何使用where子句?

Android SQLite how to use where clause?

在下面的代码中,我 selecting KEY_ROWID = 12 来自我的 Table,但现在我需要 select KEY_ROWID 大于 12但小于 20.how 我可以在下面的查询中指定 where 子句。

  mDb.query(true, SQLITE_TABLE, new String[] {
                KEY_ROWID     }, 
                KEY_ROWID + "=?" 
                new String[] {"12"},
                null, null, KEY_ITEM , null);     

我不想写 rawQuery。

像这样更改您的查询

mDb.query(true, SQLITE_TABLE, new String[] {
            KEY_ROWID     }, 
            KEY_ROWID + ">12 AND "+KEY_ROWID+ " <20", 
            null,
            null, null, KEY_ITEM , null); 

mDb.query(true, SQLITE_TABLE, new String[] {
        KEY_ROWID     }, 
        KEY_ROWID + " >? AND " + KEY_ROWID + " <?",
        new String[] {""+12, ""+20},
        null, null, KEY_ITEM , null);

试试这个查询

mDb.query(true, SQLITE_TABLE, new String[] {
            KEY_ROWID     }, 
            KEY_ROWID + " > ? AND " + KEY_ROWID + " < ?",
            new String[] {"12", "20"},
            null, null, KEY_ITEM , null);