1
I have a problem in the logging method, it is logging in with both the right login and password as with them wrong. When it logs in with wrong login the user id goes as 0 and if it logs with the correct data the id will 1 as usual?
public Usuario validarLogin(String login, String senha) {
String[] selectionArgs = new String[]{login, senha};
Cursor cursor;
cursor = db.rawQuery("select * from usuarios where login=? and senha=?", selectionArgs);
Usuario usuarioLinha = new Usuario();
if (cursor.moveToNext()) {
usuarioLinha.setId(cursor.getLong(cursor.getColumnIndex("id_usuario")));
usuarioLinha.setEmail(cursor.getString(cursor.getColumnIndex("email")));
usuarioLinha.setLogin(cursor.getString(cursor.getColumnIndex("login")));
usuarioLinha.setSenha(cursor.getString(cursor.getColumnIndex("senha")));
}
return usuarioLinha;
}
And what was supposed to happen in case of wrong user or password?
– Bacco