Change NOT LIKE to NOT IN:
Cursor c = myDB.rawQuery("SELECT * FROM " + tableName + " WHERE Field5 NOT IN " +
Arrays.toString(ALQu.toArray()).replace("[", "(").replace("]", ")") +
"ORDER BY RANDOM() LIMIT 1", null);
Question
I'm trying this query:
Cursor c = myDB.rawQuery("SELECT * FROM " + tableName + " WHERE Field5 NOT LIKE " +
Arrays.toString(ALQu.toArray()).replace("[", "(").replace("]", ")") +
"ORDER BY RANDOM() LIMIT 1", null);
but i get the following error :
03-12 18:12:34.469: E/AndroidRuntime(16604): android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: SELECT * FROM TableQ WHERE Field5 NOT LIKE (6, 9) ORDER BY RANDOM() LIMIT 1
I try to exclude the already checked fields. I add the data in an ArrayList. I don't see where is the problem. Can you help pls ?
EDIT :
Yes, it's "NOT IN", I don't know why i didn't try it , thanks
Solution
Change NOT LIKE to NOT IN:
Cursor c = myDB.rawQuery("SELECT * FROM " + tableName + " WHERE Field5 NOT IN " +
Arrays.toString(ALQu.toArray()).replace("[", "(").replace("]", ")") +
"ORDER BY RANDOM() LIMIT 1", null);