I\'m working with firebase in a android application and something strange ocurred, in my example I need two snapshots, 1 to get the users inside a list ( I use this snapshot to
This is happening because onDataChange is called asynchronously. This means that the statement that adds users to the list
is executed before onDataChange
has been called. That's why your list
is empty outside that method. So in order to use that lists, you need to use it inside the onDataChange()
method.
For other approach, please visit this post and this post.
Hope it helps.