Attempt to invoke virtual method 'void

Asked

Viewed 367 times

0

Good evening, I am not able to solve the problem, it says it has an unregistered object (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 this is it! The mistake: Attempt to invoke virtual method 'void project.henry.Count.domain.repoResult.deletar(int)' on a null Object Reference.

The code using that 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());
            }
        }
    });

1 answer

0


What is null is its object repoResultado. You must not have initialized it. Hence it gives the null reference error when trying to call the method deletar of that class.

  • It worked now, really it was not being instantiated. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.