I have the following SQLite query:
ArrayList<Long> idList = new ArrayList<>();
// adding Long values to idList
SQLiteDatabase db = getReadableDatabase();
final String whereClause = COLUMN_DEVICE_ID + " IN (?)";
final String[] whereArgs = new String[]{TextUtils.join(", ", idList)};
Cursor cursor = db.query(TABLE_DEVICES, null, whereClause, whereArgs,
null, null, null);
Executing this query results in an empty Cursor
.
It seems like the reason of the problem is the whereArgs
String
does not get inserted into the whereClause
.
I debugged the code and noticed that the mQuery
field of the Cursor
is initialized to the following:
SELECT * FROM table_devices WHERE device_id IN (?)
Why is the ?
not getting replaced with the whereArgs
?
Thanks in advance.