I have ở Firebase Database structure looks like this. enter image description here I want to get the data from red area. I have tried this code:
ref.child("shop").child("orders").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue() != null) {
for (DataSnapshot temp : dataSnapshot.getChildren()) {
Receipt temp2 = temp.getValue(Receipt.class);
}
}
}
The Receipt temp2 return null. Please someone can tell me how i can get that data. Thanks in advance Edit 1: Here is my Receipt class:
public class Receipt {
private String name;
private String province;
private String district;
private String address;
private String phoneNumber;
private String style_payment;
private int state;
private int tmp;
private int cost;
private int total;
private ArrayList<ProductInReceipt> productList;
public Receipt(){}
public Receipt(String name, String province, String district, String address, String phoneNumber, int state, ArrayList<ProductInReceipt> productList,String style_payment,
int tmp,int cost, int total) {
this.name = name;
this.province = province;
this.district = district;
this.address = address;
this.phoneNumber = phoneNumber;
this.state = state;
this.productList = productList;
this.style_payment = style_payment;
this.tmp = tmp;
this.cost = cost;
this.total = total;
}
}