Reputation: 8968
I am trying to retrieve sms by phone number but I don't get any result. (I do get results if I replace where
and where_args
by null
)
String where = "address=?";
String[] where_args = new String[]{"+33 1 23 45 67 89"};
contentResolver.query(uri, new String[]{"*"}, where, where_args, null);
I suspect that there is a problem with the ?
because of the spaces, so I tried where = "address='?'"; and
where = "address=\"?\"";` but none worked
Any idea ? Thanks !
Upvotes: 2
Views: 293
Reputation: 21091
Have you tried the following to ensure part of it works correctly?
String where = "address = '+33 1 23 45 67 89'";
contentResolver.query(uri,
new String[]{"*"},
where, null, null);
Try creating the array in the query call.
String where = "address = ?";
String where_args = "+33 1 23 45 67 89";
contentResolver.query(uri,
new String[]{"*"},
where,
new String[]{where_args},
null);
Also, check that your projection argument isn't causing issues. Set that parameter specifically to the column you are searching, at least for testing purposes, to see if that is altering the selection argument in anyway.
More examples below:
Upvotes: 1