title: Firebase: Attempting to populate an ArrayList with addListenerForSingleValueEvents, it only adds one child
body: <pre><code>DatabaseReference ref = mFirebaseDatabaseReference.child("questions");
          ref.addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
  
                  String dQuestion;
                  ArrayList&lt;Question&gt; alQuestions = new ArrayList&lt;Question&gt;();
  
                  for(DataSnapshot questionSnapshot : dataSnapshot.getChildren()){
  
                      dQuestion = questionSnapshot.child("question").getValue(String.class);
                      Question q = new Question(dQuestion);
                      alQuestions.add(q);
  
                  }
  
                  randoms[0] = (int) Math.random() * alQuestions.size();
                  randoms[1] = (int) Math.random() * alQuestions.size();
                  randoms[2] = (int) Math.random() * alQuestions.size();
                  randoms[3] = (int) Math.random() * alQuestions.size();
                  randoms[4] = (int) Math.random() * alQuestions.size();
  
                  String q1, q2, q3, q4, q5;
                  q1 = alQuestions.get(randoms[0]).getQuestion();
                  q2 = alQuestions.get(randoms[1]).getQuestion();
                  q3 = alQuestions.get(randoms[2]).getQuestion();
                  q4 = alQuestions.get(randoms[3]).getQuestion();
                  q5 = alQuestions.get(randoms[4]).getQuestion();
  
                  tvQuestion1.setText(q1);
                  tvQuestion2.setText(q2);
                  tvQuestion3.setText(q3);
                  tvQuestion4.setText(q4);
                  tvQuestion5.setText(q5);
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
  </code></pre>
  
  <p>As you can see, I've added a listener to the database reference and within the foreach loop, I'm trying to iterate all the specified children and populate the ArrayList which I'm later trying to refer to when I want to get some of the values from it.</p>
  
  <p>The problem is, this code, as it is, only puts one element in the ArrayList, over and over, or just once, not sure, but only the very first entry from the specified database location gets in the ArrayList and is displayed where I want it.</p>
  
  <p>How do I get all the children inside the ArrayList?</p>
  
  <p>EDIT:</p>
  
  <p>Database structure</p>
  
  <pre><code>survey-6d90daddclose
   questions
   -KdG_f4dckyHRBVLrYj2
   date: 
  "Sat Feb 18 09:18:34 EST 2017"
   question: 
  "Will it work properly this time?"
   -KdG_sNbmmIFiJGOWHTz
   date: 
  "Sat Feb 18 09:19:29 EST 2017"
   question: 
  "Will it work properly this time?"
   -KdGd1Nl-tifclI_Gd4e
   date: 
  "Sat Feb 18 09:33:16 EST 2017"
   question: 
  "Username: null"
   -KdHTJZ2IHvgtWpLQIyQ
   date: 
  "Sat Feb 18 13:26:04 EST 2017"
   question: 
  "Username: null"
   -KdLIycLs-Qv5zscKYIV
   date: 
  "Sun Feb 19 07:19:32 EST 2017"
   question: 
  "Q1"
   -KdLIzjSr3o-h8ewH5CL
   date: 
  "Sun Feb 19 07:19:36 EST 2017"
   question: 
  "Q2"
   -KdLJ1VhcUZQlqU2hoxA
   date: 
  "Sun Feb 19 07:19:48 EST 2017"
   question: 
  "Q3"
   -KdLJ3XxTLeOEH83fzzw
   date: 
  "Sun Feb 19 07:19:56 EST 2017"
   question: 
  "Q4"
   -KdLJ4ci6p7OLdPl4AS2
   date: 
  "Sun Feb 19 07:20:00 EST 2017"
   question: 
  "Q5"
   -KdLJ5Wz5Bk-X_U0cRwQ
   date: 
  "Sun Feb 19 07:20:04 EST 2017"
   question: 
  "Q6"
   -KdLJ6jdYaNWnr8_PfEk
   date: 
  "Sun Feb 19 07:20:09 EST 2017"
   question: 
  "Q7"
   -KdLJ7i5EzAEr6HLr__-
   date: 
  "Sun Feb 19 07:20:13 EST 2017"
   question: 
  "Q8"
  </code></pre>
  
  <p>Question class</p>
  
  <pre><code>public class Question {
  
      private String date;
      private String question;
      private String username;
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getUsername() {
          return username;
      }
  
      public Question() {
      }
  
      public Question(String date, String question, String username) {
          this.date = date;
          this.question = question;
          this.username = username;
      }
  
      public Question(String question) {
          this.question = question;
      }
  
      public String getDate() {
          return date;
      }
  
      public String getQuestion() {
          return question;
      }
  
      public void setDate(String date) {
          this.date = date;
      }
  
      public void setQuestion(String question) {
          this.question = question;
      }
  }
  </code></pre>