public int getUserCred(User user){
database = opener.getReadableDatabase();
String first = user.getFirst();
String pass = user.getPassword();
String[] cols = {COL_FIRST, COL_PASS};
userCursor = database.query(TABLE_USER, cols, null, null, null, null, null);
if(userCursor != null & userCursor.moveToFirst()) {
String firstName = userCursor.getString(userCursor.getColumnIndex(COL_FIRST));
String password = userCursor.getString(userCursor.getColumnIndex(COL_PASS));
if(first.equals(firstName) & pass.equals(password)){
return User.CRED_CORRECT;
}
}
database.close();
userCursor.close();
return User.CRED_INCORRECT;
}
there's my code as it is now, though an illegalStateException keeps getting thrown at me saying it can't access row 0 col -1. now i know in fact the data is held in the cursor because cursor.getString(0) and cursor.getString(1) is returning the data, but using cursor.getColumnIndex(COL_(FIRST/PASS)) keeps raising the exception. can somebody please explain to me why it's doing this to me? originally i held all SQLITE schema statements in an interface, which is what i thought was causing the problem for some reason, but then putting them in a nested class raised the same exception, so i decided to make them class variables in my SQLiteOpenHelper subclass but that still didn't change my getColumnIndex() situation i got going on. so if someone can point me in the right direction i'd be extremely grateful! thanks!
Aucun commentaire:
Enregistrer un commentaire