Reputation: 54949
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.
Upvotes: 1
Views: 2343
Reputation: 11923
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.
Upvotes: 0
Reputation: 48577
Your function returns a Cursor
public Cursor checkUsername()
Either change it to return a boolean, or return a cursor.
Upvotes: 4