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 making a mistake on that line:
boolean isInsertForma = dbApp.insertFormaPagamento(
Error presented:
FATAL EXCEPTION: maijava.lang.NullPointerException
at app.teste1.ActDetalheCheckout$1.onClick(ActDetalheCheckout.java:65
Before calling an object method it is necessary to instantiate the class.
– ramaral
Where are you instantiating dbApp?
– Jorge B.
Only with the code shown you cannot guess which of the objects is null. I suggest putting each of these objects into variables and tracking their values by the debugger.
– Vítor Martins
Only with this piece of code can’t be sure which part is causing the Nullpointer. It may mean that some of the parameters you are passing to the method
insertFormaPagamento()
is null or thatdbApp
is null or may have another cause. I suggest you try debugging your code, add a breakpoint in the error line and check the value of all arguments and follow the execution of the program step by step.– Julian
Guys, I managed to tidy up. I had forgotten to instantiate the object "dbApp", as the ramaral and Jorge had spoken. Thank you very much.
– Gabriel Souza
@Gabrielsouza You can post below the answer to your own question, there maybe if someday someone has the same problem, already see your answer.
– viana