First off, here's my Database structure:
My goal was to get a random Question object from the "DE" node to later display it, and as there's no builtin support for querying a random child I have to get a random Object myself, from that iterator, somehow.
Currently, I have this code, but am confused on how to string it together:
DatabaseReference questionsRef = FirebaseDatabase.getInstance().getReference().child("questions").child("DE");
questionsRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
int questionCount = (int) dataSnapshot.getChildrenCount();
int rand = random.nextInt(questionCount);
Iterator itr = dataSnapshot.getChildren().iterator();
}
// onCancelled(){}
});