Hello, could anyone help me, the update is not updating the data!
Follow the button that calls the method:
@Override
public void onClick(View v) {
Receita rec = new Receita();
String dosradio = null;
switch(rg.getCheckedRadioButtonId()){
case R.id.rbCmp:
dosradio = "cmp";
break;
case R.id.rbMl:
dosradio = "ml";
break;
}
if (getIntent().getExtras() == null){
rec.setMedicamento(txtMedi.getText().toString());
rec.setDosagem(txtDos.getText().toString());
rec.setHorario(spn1.getSelectedItem().toString());
rec.setVencimento(txtDt.getText().toString());
rec.setdosradio(dosradio.toString());
bdhelper.insertRec(rec);
}
else{
rec.setMedicamento(txtMedi.getText().toString());
rec.setDosagem(txtDos.getText().toString());
rec.setHorario(spn1.getSelectedItem().toString());
rec.setVencimento(txtDt.getText().toString());
rec.setdosradio(dosradio.toString());
bdhelper.updateReceita(rec);
}
}
public void updateReceita(Receita rec)
{
db = getWritableDatabase();
ContentValues editContact = new ContentValues();
editContact.put("medicamento", rec.getMedicamento());
editContact.put("dosagem", rec.getDosagem());
editContact.put("dosradio", rec.getdosRadio());
editContact.put("horario", rec.getHorario());
editContact.put("venciment", rec.getVencimento());
db.update("tab", editContact, "_id=" + rec.getId(), null);
db.close();
} //