Hello, I read the records from the firebase and insert them into an array of objects. The Json class has only the business fields and does not have the key field. To delete an evaluation record the best approach would be to change the Json class and insert the key field. Is this the best approach? Thank you.
// I want to delete the record in this method
listviewCompras.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int pos, long id) {
// TODO Auto-generated method stub
Log.v("long clicked","pos: " + pos);
return true;
}
})
;
// Code that retrieves data from the database.
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
//habilitando o botao pata evitsr dula entras
buttonSave.setEnabled(true);
ParcelaCartao parcela = new ParcelaCartao();
ArrayList<ParcelaCartao> array = new ArrayList<>();
for (DataSnapshot childSnapshot : snapshot.getChildren())
{
parcela = childSnapshot.getValue(ParcelaCartao.class);
array.add(parcela);
}
monta_listview(array);
ClassPrice Class
import com.google.firebase.database.*;
import java.util.*;
import java.text.*;
/**
* Created by Belal on 2/23/2016.
*/
//@JsonIgnoreProperties
@IgnoreExtraProperties
public class ParcelaCartao
{
private String descricao;
private long parcelas;
private double valor;
private String datacompra;
private String dataultparcela;
public ParcelaCartao(String descricao, long parcelas ,double valor, String datacompra, String dataultparcela)
{
setDescricao(descricao);
setParcelas(parcelas);
setValor(valor);
setDatacompra(datacompra);
setDataultparcela(dataultparcela);
}
public ParcelaCartao() {
/*Blank default constructor essential for Firebase*/
}
public void setParcelas(long parcelas)
{
this.parcelas = parcelas;
}
public long getParcelas()
{
return parcelas;
}
public String getDescricao()
{
return descricao;
}
public void setDescricao(String descricao)
{
this.descricao = descricao;
}
public double getValor()
{
return valor;
}
public void setValor(double valor)
{
this.valor = valor;
}
public String getDatacompra()
{
return datacompra;
}
public void setDatacompra(String data_compra)
{
this.datacompra = data_compra;
}
public String getDataultparcela()
{
return dataultparcela;
}
public void setDataultparcela(String datault_parcela)
{
this.dataultparcela = datault_parcela;
}
@Override
public String toString() {
return "Compra: " + descricao +
"\n num_parcelas: " + parcelas + " valor: " + valor +
"\n data compra: " + datacompra +
"\n data ult parcela: " + dataultparcela;
}
}