title: Push list of data to firebase not working
body: <p>I am trying to use the firebase push() function, as I want to add a list off data to an allready existing list. The setValue() function overwrites existing data.</p>
  
  <p>This is what I used to do:</p>
  
  <pre><code> DatabaseReference childref =  mDatabase.child("users").child(uih.getUserData().getUsername()).child("answered_questions");
                          childref.setValue(getAnsweredQuestions(questionViewList));
  </code></pre>
  
  <p>This worked, but every time I use this function the data is overwritten and this is not what I want. I tried using the Push function as described by the firebase documation: <a href="https://firebase.google.com/docs/database/android/save-data" rel="nofollow noreferrer">https://firebase.google.com/docs/database/android/save-data</a></p>
  
  <p>I am not sure I am doing it right, but it is not working. And this is when I tried to implement the push() function:</p>
  
  <pre><code>DatabaseReference childref =  mDatabase.child("users").child(uih.getUserData().getUsername()).child("answered_questions");
                      String key = childref.push().getKey();    
                      Map&lt;String, Object&gt; childUpdates = new HashMap&lt;&gt;();
                      childUpdates.put( key, questionViewList);
                      mDatabase.updateChildren(childUpdates);
  </code></pre>
  
  <p>The exception I get is:</p>
  
  <pre><code>com.google.firebase.database.DatabaseException: Failed to parse node with class class scrambled.nl.generationr.QuestionView
  </code></pre>
  
  <p>And this is weird, since I did not receive this error while doing the setValue method. Can anyone explain what I am doing wrong and how I should push a list to firebase?</p>
  
  <p><strong>edit:</strong></p>
  
  <p>What I can do is:</p>
  
  <pre><code>DatabaseReference childref =  mDatabase.child("users").child(uih.getUserData().getUsername()).child("answered_questions");
                              childref.push().setValue(getAnsweredQuestions(questionViewList));
  </code></pre>
  
  <p>In added the push() here. This works, but instead of just increasing my list, i add another layer in my list so I actually get an array of arrays instead of a longer list.</p>
  
  <p>See here the result:</p>
  
  <p><a href="https://i.stack.imgur.com/gCyVO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gCyVO.png" alt="enter image description here"></a></p>