2017-04-09 90 views
-2

我已經通過在另一類putExtra和getStringExtra方法檢索的2個值的條款。 BO這些值是正確的。我需要在我的SQL查詢中使用這兩個值:的SQLite rawQuery與多個WHERE

final Cursor cursor = sdb.rawQuery("SELECT match_player_name FROM match_response WHERE match_date=? AND " + 
      "match_response =?"+new String [] {String.valueOf(date),String.valueOf(response)}, null); 

我不熟悉使用rawQuery的條件超過1的情況。我有正確的語法嗎?我在我的SQLite數據庫中有記錄滿足這種條件。

+0

'我有沒有正確的語法'** NO **。字符串數組必須代替'null' –

回答

2

這是一個例子:

​​
0
public Cursor getMachineServices(){  
SQLiteDatabase db = this.getReadableDatabase(); 
      Cursor c = db.rawQuery("select row1, from maquina where something = x AND somethingelse = y", new String[]{}); 
      return c; 

} 

然後在你的活動要顯示它您必須做到:?

Database db; 

db = new Database(yourActivity); 
      Cursor c = db.getMachineServices); 

      if (c.moveToFirst()) { 

       do { 




      String machines 
c.getString(c.getColumnIndex("row1")); 
         //you can use the variable machines where you want 


        } while (c.moveToNext()); 

       }