How to use getContentResolver().query for Multiple selectionargs?
I am trying to use getContentRsolver().query()
with multiple selectionargs but not able to figure out the correct syntax. I am getting "SQLiteException: bind or column index out of range"
contactNumberArray
is a string array which has all the contact numbers.
getConte开发者_C百科ntRsolver().query(CONTENT_URI, Projection, caller_number + "=?", contactNumberArray, null);
This query works fine if I have only one contact number in the string array but it doesn't work if I have multiple contact numbers. Is there any specific way to query for multiple selectionargs ?
Please let me know if anyone has any pointers regarding this issue ?
Is there any specific way to query for multiple selectionargs
First, your SQL syntax is wrong. You need to use the IN
operator, not =
, if you are expecting multiple possible values on the right-hand side of the comparison.
Second, AFAIK, you cannot use positional parameters for this.
You can use caller number in (?,?,...)
where count of ?
is your contactNumberArray
's length. You can also use caller number=? OR caller number=?
.
精彩评论