0

When String[] ids has one argument, query return data, when more then one, get error: Cannot bind argument at index X(number of arguments) because the index is out of range. The statement has 1 parameter.

Cursor  cr = ctx.getContentResolver().query( 
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
    null, 
    "_id = ?",
    ids,
    orderBy
);
stealthjong
  • 10,858
  • 13
  • 45
  • 84

1 Answers1

0
"_id = ?"

This construction serves to reserve place for one parameter. If you want to select items with several ids you better use the folowing:

"_id IN (?,?,?..?)"

Here is the answer about parametrization of this type of query: IN clause and placeholders

Community
  • 1
  • 1
vokilam
  • 10,153
  • 3
  • 45
  • 56