I have this query
public Cursor control(String a){
return mDb.query(ProductsMetaData.C_TABLE, null,ProductsMetaData.A+ "=?" , new String[] {String.valueOf(a)}, null, null, null, null);
}
and it works.
Now I need to implement the “AND” because I want only rows where ProductsMetaData.A = a and ProductsMetaData.B = b but what I’m doing doesn’t work.
public Cursor control(String a, String b){
return mDb.query(ProductsMetaData.C_TABLE, null,ProductsMetaData.A+ "=?" + ProductsMetaData.B + "=?" , new String[] {String.valueOf(a), String.valueOf(b)}, null, null, null, null);
}
Could someone help me?
You simply need to add the
ANDkeyword:Also your parameters
aandbare already Strings, so you can simply use:Delete is easy enough:
Updates require a ContentValues object:
One final note, if you find yourself using
ProductsMetaData.A + "=? AND " + ProductsMetaData.B + "=?"numerous times, you can save it in astatic finalvariable just likeC_TABLE,A, andB: