How use "LIKE" and "%" to check similarity to variable in android(Java code) -


i working on android app using java, need query database in java code check if userinput(variable) statement contain words in sqlite database using like in query , rowquery method in java code,

i used code did not work:

cursor = db.rawquery("select shompet sentence " + column + " '%"                               + newmessage + "%'", null); 

newmessage variable(userinput)

i read similar topics either not answer or complicated.

in expression 'hi' '%hi there%', not possible find any characters replace % wildcards strings match.

you need comparison other way around, i.e., 'hi there' '%hi%':

db.rawquery("select shompet sentence" +             " ? '%' || " + column + " || '%'",             new string[] { newmessage }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -