1

I am trying to do a check if the User-name entered by the user exists in the DB.

public Cursor checkUsername(String username) throws SQLException {
    Cursor mCursor = db.query(true, TABLE_USERS, new String[] { ID,
            KEY_NAME, KEY_USERNAME}, KEY_USERNAME + "="
            + username, null, null, null, null, null);
    if (mCursor != null) {
        return true;
    }
    return false;
}

When i return true or false i am getting an Error saying

Type mismatch: cannot convert from boolean to Cursor

i just want to return true or false from the DBAdaptor back to the Activity.

2 Answers 2

4

Your function returns a Cursor

public Cursor checkUsername()

Either change it to return a boolean, or return a cursor.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for it :) i was checking in the Activity :) changed it to public Booleam :)
Sounds like your sql table doesn't have a column "harsha"
but on the sql query its not asking for the column harsha either :(
0

Try reformatting your sql query and provide the 'where' clause as one of the parameters in the database call :

public Cursor getRoute(long rowIndex)
{
    String where = KEY_ID + "=" + rowIndex;
    return db.query(TBL_ROUTES, null, where, null, null, null, null);       
}

Also, remember to close your cursor when you are finished with it, otherwise you will get other exceptions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.