Like keyword in db.rawQuery with parameter
You can use "?" as the placeholder in sql for parameter in db.rawQuery in Android
For example
Code
String sql= "select Id , Name, Note from note | |
where Name = ?"; | |
Cursor c = db.rawQuery(sql, new String[] { name.toUpperCase() }); |
How about "Like" keyword with two "%".
You cannot do that :
Code
String sql= "select Id , Name, Note from note | |
where Name like %?%"; | |
Cursor c = db.rawQuery(sql, new String[] { name.toUpperCase() }); |
You have to do that like:
Code
String sql = "select from " + NoteTable.TABLE_NAME + " where upper(" + NoteTable.NoteColumns.NOTE + ") LIKE ? "; | |
Cursor c = db.rawQuery(sql, new String[] { "%"+name.toUpperCase() +"%" }); |
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 229 feedbacks awaiting moderation...
Form is loading...