The reference of SQLiteDatabase says:
You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings.
I'm guessing that this last bit about the values bound as Strings could be the cause of the issue somehow.
In any ase I have a workaround for you: use the rawQuery
method instead, crafting your SQL string like this:
String sql = String.format("SELECT * FROM %s WHERE %s = %d AND %s = %d AND %s = %d",
Article.TABLE_NAME,
Article.COL_CATEGORY_ID, category.getId(),
Article.COL_TOPIC_ID, topic.getId(),
Article.COL_QUESTION_ID, question.getId());
This is not as efficient as binding the parameters (since here we cannot benefit from prepared statements), but for all practical purposes, it's probably good enough. I use this style quite a lot, as I find it easier to read.
Update
The equivalent of the following also works for me in one of my apps:
String sql = String.format("SELECT * FROM %s WHERE %s = ? AND %s = ? AND %s = ?",
Article.TABLE_NAME,
Article.COL_CATEGORY_ID,
Article.COL_TOPIC_ID,
Article.COL_QUESTION_ID);
String args = new String[] { category.getId(), topic.getId(), question.getId() };
Cursor cursor = getReadableDatabase().rawQuery(sql, args);
That is, binding arguments works for me, whether they are text columns or integer columns. I hope you can get it to work too.