I am trying to get all the data about receta from my firebase real time database (Link to my firebase recetas image)
image
When I get the data from it using the code below, I get all the data but description and origin that is set to null
database = FirebaseDatabase.getInstance();
recetasReference = database.getReference().child("recetas");
recetasReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot ds: dataSnapshot.getChildren()){
Receta new_receta = ds.getValue(Receta.class);
recetas.add(new_receta);
}
myAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(getApplicationContext(), "Error al mostrar",
Toast.LENGTH_LONG)
.show();
}
});
I tried debuggin, ds has the descripcion and origen correctly but i do not why they are set to null when creating the receta.
ds
receta
Any Idea?
Sorry if i made any mistake on the post, it is my first one.
Receta class:
public class Receta {
private String name;
private String autor;
private String desc;
private String origin;
private String tiempoPrep;
private String filepath;
public Receta(String user, String nombre, String
descripcion, String origen, String tiempo
, String filepath) {
this.autor = user;
this.name = nombre;
this.desc = descripcion;
this.origin = origen;
this.tiempoPrep = tiempo;
this.filepath = filepath;
}
public Receta(String user, String nombre, String
descripcion, String origen, String tiempo) {
this.autor = user;
this.name = nombre;
this.desc = descripcion;
this.origin = origen;
this.tiempoPrep = tiempo;
}
public Receta(){}
public String getNombre() {
return name;
}
public void setNombre(String nombre) {
this.name = nombre;
}
public String getAutor() {
return autor;
}
public void setAutor(String autor) {
this.autor = autor;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getOrigin() {
return origin;
}
public void setOrigin(String origen) {
this.origin = origen;
}
public String getTiempoPrep() {
return tiempoPrep;
}
public void setTiempoPrep(String tiempoPrep) {
this.tiempoPrep = tiempoPrep;
}
public String getFilepath() {
return filepath;
}
public void setFilepath(String filepath) {
this.filepath = filepath;
}
}