1

在我的代码中,我有一个数据库,当我使用 检索行时KEY_DESC = userselectvalue,它起作用了。但是,当我尝试检索具有多个“where”条件的行时,它失败了。我曾经在ListView. 请帮我。没有错误显示。但是ListView是空白的。

 public Cursor fetchEventByName(String inputText,String inputText1) throws SQLException {
        //Log.w(TAG, inputText);
        SQLiteDatabase db = this.getReadableDatabase();

        Cursor mCursor = null;
        if ((inputText == null || inputText.length () == 0) && (inputText1 == null || inputText1.length () == 0 ) ){
        mCursor = db.query(DATABASE_TABLE, new String[] {KEY_ROWID,
                KEY_DESC, KEY_EVENT, KEY_DATE },
        null, null, null, null, null);
        }
        else {

            String [] temp = new String[] {KEY_ROWID,
                    KEY_DESC, KEY_EVENT, KEY_DATE};
        mCursor = db.query(false,DATABASE_TABLE,temp ,
                KEY_DESC + " = '" + inputText + "'" + " AND " + KEY_DATE + " = '" + inputText1+ "'", null, null, null, null, null);


        }

        if (mCursor != null) {
        mCursor.moveToFirst();
        }
        return mCursor;
   }
4

1 回答 1

0

You could try db.rawQuery by passing sql queries directly.

于 2013-08-14T12:00:19.653 回答