title: Firebase Database multiple strings in one child
body: <p>im working with firebase for a couple months and so far i had no issues until now. im using kotlin and my problem is simple but i cant find a way out. i storage strings in database: path"/user/friends" , but i cant change the variable name and the strings were overwriting itselves. My solution was use "push()" until the "setValue()", but with this i have the following firebase structure:</p>
  
  <pre><code>"users": {
      "yvrYpjMwVSPBvMAvDGo26hPlWWQ2": {
          "email": "vinibarros.sp@gmail.com",
          "friends": {
              "-LfD9z6ke7FXFjxUb4td": {
                  "email": "teste@gmail.com"
              },
              "-LfDA-NaAYAMoWiPhXy4": {
                  "email": "teste2@gmail.com"
              }
          },
          "primeiroLogin": true,
          "stars": 0,
          "tutorialComplete": false,
          "uid": "yvrYpjMwVSPBvMAvDGo26hPlWWQ2",
          "username": "Vinicius Barros"
      }
  }
  </code></pre>
  
  <p>basically hashmaps inside a hashmap ps:lol mindblow</p>
  
  <p>how do i get the pushcode.value into an arraylist?</p>
  
  <p>i have a class user that have the friend variable, until now this variable was typed as hashMap. and the call to get the email was "user.friends.value"</p>
  
  <p>this worked because was one friend....</p>
  
  <blockquote>
    <p>com.google.firebase.database.DatabaseException: Failed to convert value of type java.util.HashMap to String</p>
  </blockquote>
  
  <p>When I added more than one user I got this error that references my class user, where have a "hashMap". But the firebase gives me another hashmap instead of string. I was thinking about: <code>hashMap&lt;hashMap&lt;String,String&gt;, null&gt;</code>.</p>
  
  <p>i 've tried this:</p>
  
  <p>class friends:</p>
  
  <pre><code>@Parcelize
  class Friend(val hashMap: HashMap &lt; String, String &gt; ? ): Parcelable {
      constructor(): this(null)
  }
  </code></pre>
  
  <p>The activity where i show the friends:</p>
  
  <pre><code>val ref2 = FirebaseDatabase.getInstance().getReference("/users/" + cUid + "/friends/")
  ref2.addListenerForSingleValueEvent(object: ValueEventListener {
      override fun onCancelled(p0: DatabaseError) {
  
      }
      override fun onDataChange(p0: DataSnapshot) {
          p0.children.forEach {
              val friend = it.getValue(Friend::class.java)
              Log.d("teste", it.toString())
              if (friend != null) {
                  Log.d("teste", friend.hashMap ? .values.toString())
                  //friends.add(friend.hashMap?.values.toString())
              }
          }
  
      }
  
  })
  </code></pre>
  
  <p>this keeps returning null....</p>