Here is what is stored in Firebase:
"73668" : {
"id" : "73668",
"price" : "Price",
"product1" : "1. Product 1",
"product2" : "2. Product 2",
"product3" : "3. Product 3",
"status" : "not ready"
},
"a2521" : {
"id" : "a2521",
"price" : "Price",
"product1" : "1. Product 1",
"product2" : "2. Product 2",
"product3" : "3. Product 3",
"status" : "not ready"
},
"a719b" : {
"id" : "a719b",
"price" : "Price",
"product1" : "1. Product 4",
"product2" : "2. Product 5",
"product3" : "3. Product 6",
"status" : "not ready"
}
}
Here is how it was fetched in the application:
The code I am using:
public ArrayList<Order> getOrders() {
final Firebase myFirebaseRef = new Firebase("https://torrid-heat-2650.firebaseio.com/orders");
myFirebaseRef.addListenerForSingleValueEvent(new ValueEventListener() {
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot child : snapshot.getChildren()) {
Order order = new Order();
order.setProduct1(child.child("product1").getValue().toString());
order.setProduct2(child.child("product2").getValue().toString());
order.setProduct3(child.child("product3").getValue().toString());
order.setId(child.child("id").getValue().toString());
order.setPrice(child.child("price").getValue().toString());
itemsList.add(order);
}
}
public void onCancelled(FirebaseError firebaseError) {
}
});
System.out.println(itemsList.size());
return itemsList;
}
The same operation returns empty arraylist on the Android device. The interesting thing is that it outputs 0 in both cases, however returns non-null arraylist. What could result 2 different outputs in the same code? Thank you.