问题
I want to add functionality of contains()
method in where clause. Right now I was doing something like "address = ?"
and providing address in arguments but now I want to use a logic which works as address.contains(?)
and then providing the address in arguments. How can I implement it?
Till now my code is and need to know the require modification.
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
String[] projection = new String[] { "_id", "thread_id", "address",
"person", "date", "body", "type" };
Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
projection, "address = ?", new String[]{addressToBeSearched}, null);
回答1:
Try this
Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
projection, "address LIKE ?", new String[]{addressToBeSearched + "%" }, null);
来源:https://stackoverflow.com/questions/16771636/where-clause-in-contentproviders-query-in-android