Android datasnap,android - How to retreive all data from datasnapshot AndroidStudio? - Stack Overflo...

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;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值