NullPointerException error when calling a method

0
public void addFormaPagamento() {
    btnAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            boolean isInsertForma = dbApp.insertFormaPagamento(
                    spnForma.getSelectedItemPosition(),
                    spnParcelas.getSelectedItem().toString(),
                    edtvalor.getText().toString()
            );

            if (isInsertForma == true) {
                verifica_Add_Forma += 1;
                Toast.makeText(ActDetalheCheckout.this, "Forma de Pagamento Inserida com Sucesso", Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(ActDetalheCheckout.this, "Falha os Inserir Forma de pagamento", Toast.LENGTH_LONG).show();
            }
        }
    });
}

You're giving this line an error:

boolean isInsertForma = dbApp.insertFormaPagamento(

Error presented:

FATAL EXCEPTION: maijava.lang.NullPointerException
at app.teste1.ActDetalheCheckout$1.onClick(ActDetalheCheckout.java:65                                                              
    
asked by anonymous 17.08.2016 / 19:04

1 answer

1

Always throwing a NullPointerException exception means that it is trying to access an object and / or null variable.

In your case you are calling the insertFormaPayment of the dbApp object that should not be instantiated.

Or put a test before to see if dbApp! = null, or check why it is not being instantiated.

    
18.08.2016 / 23:54