Skip to content
Advertisement

How to check recyclerview is empty or not using dataSnapshot.hasChildren()

I am using firebasedatabase to show my data into recyclerview. I want to show simple toast when my recyclerview is empty and i am using dataSnapshot.hasChildren() for checking the database haschildren or not. here is code

JavaScript

when data is available the dataSnapshot.hasChildren() giving true value but when no data available else condition is not working

Advertisement

Answer

you can use dataSnapshot.getChildrenCount()

JavaScript

Update:

check the else condition for the .exists() for empty list

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement