Is There Any Chance Datasnapshot Value Is Null?
I am answering this question then this new question come to my mind. In that question, I describe my example code like this: boolean firstCallDone = false; boolean secondCallDone =
Solution 1:
The DataSnapshot can never be null, regardless of whether there is data there or not (since you'll get an empty but non-null DataSnapshot if there is no data).
Solution 2:
No, the DataSnapshot
value will never be null
.
If any failure occurs, onCancelled()
method will be triggered instead.
By the way, instead of creating flags to make sure that each listener is finished, you should instead take advantage of Tasks API to manage these tasks. This answer from a Firebaser explains about this and also provides a class for that.
Cheers :)
Post a Comment for "Is There Any Chance Datasnapshot Value Is Null?"