I'm using an SQLite database to store items. When I call items by their ids using where clause and selection args. If I pass a selection args array with more than one item id, it crashes with error:
Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.
Here is how I perform the query:
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
loaderId = id
val selectionArgs = arrayOf("2", "1")
return CursorLoader(activity!!,
MenuContract.ItemEntry.CONTENT_URI,
Constants.ITEM_PROJECTION_COLUMNS,
MenuContract.ItemEntry._ID + "=?",
selectionArgs,
null
)
}
It works fine if the selectionArgs array contains only one id. Not sure why.