I have the variable string (user gets to set it via a ListView with tickboxes, so string can contain any number of fruits)
private static final String kernset = "Banana, Peach"
I have the following SQLite Query
Cursor cursor = db.query (TABLE_NAME, new String[] {
WOORD },
"kern IN (\"Banana\", \"Apple\")", null, null, null, null, null);
I want to replace the (\”Banana\”, \”Apple\”) part of the query with the variable.
How should I do that?
Thanks!
If you want to place a variable into your
selectionparameter, you can split your string using split method, and then form your selection likehowever if you wish to use
?inselectionand replace it withselectionArgs[]it seems to be imposible since values passed inselectionArgsare surrounded with' '. You can however form selection with?instead of actual values (likekern IN (?, ?, ?))and then passinItemsviaselectionArgs[]