问题
My query is regarding the creation of the function parameters for getting data from the database.
I want the cursor to returns only specific rows instead of complete recordset.
c= getContentResolver().query(uri, null, "column1=? \"mysearch\" or column2=? "\mysearch"\", null, "date DESC");
I want to get the results where column1 like "mysearch" or column2 like "mysearch".
In the above example i have tried with some hardcoded values.
Regards,
Nirav
回答1:
Got it after some workaround.
The correct query will be
String searchQuery = "column1 like '%" + searchKey
+ "%' or column2 like '%" + searchKey + "%'";
c = getContentResolver().query(uri, null, searchQuery, null,
"date DESC");
Thanks,
Nirav
来源:https://stackoverflow.com/questions/14498958/getcontentresolver-query-android-where-clause