Attempt to invoke virtual method 'void

0

Good night, I can not solve the problem, it says that it has an object not referenced (null object reference), but it does not have to initialize the following code:

public void deletar(int id)
    {
        conn.delete("RESULTADO", "_id = ?", new String[] { String.valueOf(id)});
    }

He says it's here! The error: Attempt to invoke virtual method 'void project.henry.count.domain.repoResult.deletar (int)' on a null object reference .

The code that uses this method:

Button btnApagar;
...
    btnApagar = (Button) findViewById(R.id.btnApagar);
    btnApagar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try{
                repoResultado.deletar(dados.getId());
            } catch (Exception ex){
                mensagem("ERRO: " + ex.getMessage());
            }
        }
    });
    
asked by anonymous 16.07.2017 / 03:13

1 answer

0

What is null is its repoResultado object. You should not have initialized it. So it gives the null reference error when it tries to call the deletar method of this class.

    
16.07.2017 / 14:25