Android - Is this Code correct?
is the below mentioned code correct
public boolean checkRecipe(CharSequence recipename) throws SQLException
{
Cursor checkRecursor=rDb.query(true, DATABASE_TABLE, new String[]{KEY_TITLE},
KEY_TITLE+"="+recipename, null, null, null, null, null);
if(checkRecursor!=null)
return true;
开发者_开发知识库else
return false;
}
I'm trying to check whether a given entry is present in the table or not.
Your recipename is a string, you must put quotes around it
Cursor checkRecursor=rDb.query(true, DATABASE_TABLE, new String[]{KEY_TITLE},
KEY_TITLE+"= '"+recipename + "'", null, null, null, null, null);
精彩评论