tags:

views:

43

answers:

1

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.

A: 

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);
fedj
I did this KEY_TITLE+"="+"\""+recipename+"\""Thank you fedj
Santosh V M