2017-04-09 46 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()); 

       }