开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜