0
I have a recipe registration screen that contains a Checkbox called "received", I would like to know how to insert in the sqlite a tinyint and then redeem when I want to consult this recipe. Ex : I create a recipe and leave the check received empty, save this recipe and when I consult to edit, this checkbox come empty, or otherwise, if I insert with check received on, when editing it come on.
Revenue class
public class Receita {
private Float valor;
private String data;
private String descricao;
private boolean recebido;
private int idGrupo;
private int idSubgrupo;
private int idUsuario;
private boolean sincronizado;
private Date incluidoEm;
private int id;
public Float getValor() {
return valor;
}
public void setValor(Float valor) {
this.valor = valor;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public boolean isRecebido() {
return recebido;
}
public void setRecebido(boolean recebido) {
this.recebido = recebido;
}
public int getIdGrupo() {
return idGrupo;
}
public void setIdGrupo(int idGrupo) {
this.idGrupo = idGrupo;
}
public int getIdSubgrupo() {
return idSubgrupo;
}
public void setIdSubgrupo(int idSubgrupo) {
this.idSubgrupo = idSubgrupo;
}
public int getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(int idUsuario) {
this.idUsuario = idUsuario;
}
public boolean isSincronizado() {
return sincronizado;
}
public void setSincronizado(boolean sincronizado) {
this.sincronizado = sincronizado;
}
public Date getIncluidoEm() {
return new Date();
}
public void setIncluidoEm(Date incluidoEm) {
this.incluidoEm = incluidoEm;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Method of searching the bank
public Receita passarTela(int id) {
Receita receita = new Receita();
Cursor c = getWritableDatabase().query(TABELA, COLUNAS, " _id = " + id, null, null, null, null);
while (c.moveToNext()){
String[] aux = c.getString(1).split("-");
receita.setValor(c.getFloat(0));
receita.setData(aux[2] + "/" + aux[1] + "/" + aux[0]);
receita.setDescricao(c.getString(2));
receita.setRecebido(c.getString(3).equalsIgnoreCase("0"));
receita.setIdSubgrupo(c.getInt(4));
receita.setId(c.getInt(8));
}
c.close();
return receita;
}
Method you insert into the seat
public void inserir(Receita receita) {
ContentValues valores = new ContentValues();
valores.put("valor", receita.getValor());
valores.put("data", receita.getData());
valores.put("descricao", receita.getDescricao());
valores.put("recebido", receita.isRecebido());
valores.put("idsubgrupo", receita.getIdSubgrupo());
valores.put("incluidoem", receita.getIncluidoEm().toString());
valores.put("sincronizado", receita.isSincronizado());
getWritableDatabase().insert(TABELA, null, valores);
}
Allan Chrystian, you have to learn that no matter how much you think you don’t need to present your codes, you need to present.
– Lollipop
@Lollipop I know I need, I just don’t know which ones I need to present, but I’ll edit what I have here. Thank you
– Allan Chrystian
Your code will show us what you already have.
– Lollipop
edited @Lollipop
– Allan Chrystian
Your question is too broad. There are many steps to achieving this answer. You have to first try to search something in google, study and come here ask something more specific, example: You tried to create a checkbox and tried to enter your values in the bank, but it is giving error. You come here and ask: Checkbox data does not insert into Sqliter. Presents your codes, explains the steps you have reached.
– Lollipop
Okay, I’ll take another look outside Google, thanks for the tip @Lollipop
– Allan Chrystian
Good studies!!!
– Lollipop