I am having problems creating queries with parameters in a database on the Android platform (2.2). I created the table as follows:
db.execSQL("CREATE VIRTUAL TABLE " + Msg._TABLE_NAME + " USING FTS3 ("
+ Msg._ID + " INTEGER, "
(...)
+ Msg.READ + " SHORT DEFAULT 0,"
+ Msg.URGENT + " SHORT DEFAULT 0"
+ ");");
Then I try to execute the query using a parameterized query:
String[] columns = new String[] {Msg.ROWID, Msg.TITLE, Msg.READ, Msg.URGENT};
(...)
getContentResolver().query(Msg.CONTENT_URI, columns,
Msg.URGENT + "=? AND " + Msg.READ + "=?" + , whereArgs, null);
where whereArgschanges for each request:
String[] urgentUnread = new String[]{"1", "0"};
String[] regularUnread = new String[]{"0", "0"};
but no matter what, it returns 0 results / rows, even if the data exists. The content provider does not change the parameters, and the query returns nothing using QueryBuilder, as well as when calling the query directly:
Cursor c = db.query(tables, columns, where, whereArgs, groupBy, having, orderBy, limit);
The query works if I just concat string:
getContentResolver().query(Msg.CONTENT_URI, columns,
Msg.READ + "=0 AND " + Msg.URGENT + "=1", null, null);
, , param- . Dalvik ( ), , , '?'. , :)
, JavaDoc , StringS, ... ... ... WTF
?
.