samedi 16 juillet 2016

Android dynamic query sql using like

I would make a query using like , using the % and a dynamic string, but i can't do it correctly. I have a:

public Cursor query(String s)
 {
String whereClause=COL_ATTRIBUTI + " like '%?%'";
String[] whereArgs=new String[] {s};
 return  getWritableDatabase().query(TABELLA_RICETTE,null,whereClause,whereArgs,null,null,null);
}

COL_ATTRIBUTI is the name of a column and TABELLA_RICETTE the name of the table. I would like to obtain all the thing that have s somewhere, so i use the %. but my app crash. What is the correct syntax?

Aucun commentaire:

Enregistrer un commentaire