Problem with login using sqlite

1

My method is not returning the teacher logged in.

    public Professor autenticarUsuario(String usuario, String senha) {

    String SQL = "select * from PROFESSOR where USUARIO = ? and SENHA = ? ";
    String[] selectionArgs = new String[] { usuario, senha };
    Cursor cursor = dataBase.rawQuery(SQL, selectionArgs);
    int idRow;
    Professor professor=null;

    if (cursor.getCount() > 0){
        if (cursor.moveToFirst()){
            professor = new Professor();
            idRow = cursor.getInt(cursor.getColumnIndexOrThrow("rowid"));
            professor.setCodProfessor(cursor.getString(cursor.getColumnIndexOrThrow("CODPROF")));
            professor.setNomeProfessor(cursor.getString(cursor.getColumnIndexOrThrow("NOME")));
            professor.setUsuario(cursor.getString(cursor.getColumnIndexOrThrow("USUARIO")));
            professor.setSenha(cursor.getString(cursor.getColumnIndexOrThrow("SENHA")));
        }
    }
    cursor.close();

return teacher;} '

Table:

  CREATE TABLE PROFESSOR"+
                    "(CODPROF VARCHAR(10) PRIMARY KEY,"+
                    "NOME VARCHAR(40),"+
                    "USUARIO VARCHAR (60),"+
                    "SENHA VARCHAR (60));"
    
asked by anonymous 09.09.2016 / 04:27

1 answer

1

Do not have rowid in your table. Check this line:

 idRow = cursor.getInt(cursor.getColumnIndexOrThrow("rowid"));

Hugs.

    
09.09.2016 / 04:41