I\'m trying to use the Java API to read data from a Firebase database in an Android application in the onCreate() event. In other words, I\'m trying to do the simplest read
That is the right method, and you're on the right track. The naming is just a little confusing (sorry!). If you do the addListenerForSingleValueEvent, your overridden onDataChange method will be called exactly once, with a DataSnapshot, just as you wish (and just like "ref.once('value' ...)" would do).
So you should be able to do:
// Add all polls in ref as rows
polls.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot child : snapshot.getChildren()) {
...
}
}
}