android - how to query against array of integer -
i query:
select * table field1 in (1, 2 ,3);
the field1 integer
type. field type string
be:
select * table field1 in ('1', '2' ,'3');
but in android both use selectionars string[].
string[] filter = new string("1", "2", "3"); cursor altocursor = mcontentresolver.query( uri, projection, "field1 in (?,?,?)" + filter, null);
how different field type string
, field1 type of string
. query same, how know if "1" in string[] integer
or string
:
string[] filter = new string("1", "2", "3"); cursor altocursor = mcontentresolver.query( uri, projection, "field1 in (?,?,?)" + filter, null);
confused here, anyone's appreciated!
typically data type of column querying defined integer or string.
database engine not realize if passing string or integer. moment query passed sql engine through error if placing integer values in string column without quote.
- check column querying
- if string encode them quote
- if integer can pass values as comma separated values
to test if string integer can use if (x int)
but in case android smart enough put code them-self guess
Comments
Post a Comment