I'm using Firebase in my app. I have a list of element to retrieve using this code:
FirebaseDatabase.getInstance()
.getReferenceFromUrl("myUrl")
.orderByChild("timestamp")
.addChildEventListener(this);
What's the best Approach to know if a ref url has no data inside? Because using ChildEventListener is not possible.
ChildEventListener has only these 4 methods: onChildAdded(), onChildChanged(), onChildRemoved(), onChildMoved().
None of these method is called in case of your object has no item inside.
So my question is. Do I have to use a ValueEventListener as well? I guess onDataChange() is called if no item has been found.
A possible scenario: You have a list of item to retrieve and populate using ChildEventListener. You want to cover the case when no item has been retrieved. So show a text "No data" instead of the list.
dataSnapshotinChildEventListeneris one level deeper thandataSnapshotproduced byValueEventListener, so unfortunately this will not work - koceeng