title: Firebase "Failed to convert a value of type java.util.HashMap to int"
body: <p>At this line of my code in my <code>OnDataChange()</code> method in the <code>ValueEvenListener</code>:</p>
  
  <pre><code>int latest = dataSnapshot.getValue(Integer.class);
  </code></pre>
  
  <p>I'm getting a <code>DatabaseException</code> with the error <code>Failed to convert a value of type java.util.HashMap to int</code>.</p>
  
  <p>However, in my database, you can take a look at the image  below:</p>
  
  <p><a href="https://i.stack.imgur.com/c3OTm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c3OTm.png" alt="enter image description here"></a></p>
  
  <p>It is obviously not a <code>HashMap</code> but an <code>int</code>. Is this a bug or am I doing something wrong? What can I do to fix it? Why is it retrieving a <code>Hashmap</code> when the value is <code>int</code>?</p>
  
  <p><strong>Full dataSnapshot:</strong></p>
  
  <pre><code>final DatabaseReference database = FirebaseDatabase.getInstance().getReference();
          database.child("Campaigns").child(key).child("count");
          database.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  int latest = dataSnapshot.getValue(Integer.class);
                  button.setText(latest + "");
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Toast.makeText(context, context.getString(R.string.error) + ": " + databaseError.getMessage(), Toast.LENGTH_SHORT).show();
              }
          });
  </code></pre>
  
  <p><strong>Database:</strong></p>
  
  <pre><code>Campaigns:{
    -JDKKDJIIDJFIDJKDK:{
        count:2432
     }
  }
  </code></pre>