dimanche 8 novembre 2015

Cannot use Like statement in Android SQLite with argument and % character

Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters.

Android doesn't recognise ? character in ?%

I try to achieve this:

 String selectQuery = "SELECT * FROM config WHERE Directory Like '?%';";

 SQLiteDatabase db = this.getReadableDatabase();
 Cursor cursor = db.rawQuery(selectQuery, new String[] {parent});

I have searched for a solution but couldn't find anything, I think it's pretty particullary. I am trying to do it like this because I want to make the query work with Strings that contains character '.

Maybe someone who had the same problem can answer me how can I solve this.

Aucun commentaire:

Enregistrer un commentaire