title: Getting 'java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map' while trying to fetch data from firebase
body: <p>I'm trying to fetch some data from <code>Firebase</code>, but getting this error: <code>java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map</code> while trying to do so.</p>
  
  <p>Here's what I'm trying;</p>
  
  <pre><code>    public void retrieveUserCounterAccepted() {
              databaseReferenceUsers = FirebaseDatabase.getInstance().getReferenceFromUrl("https://appname-e1a13.firebaseio.com/users/");
              databaseReferenceUsers.child(uid).addChildEventListener(new ChildEventListener() {
                  @Override
                  public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                      // error on the line below
                      newRequestAcceptedCounter = (Map&lt;String, String&gt;) dataSnapshot.getValue();
                      // error on line above
                      String requestAcceptedCounter = newRequestAcceptedCounter.get("requestsAccepted");
                      String requestsPostedCounter = newRequestAcceptedCounter.get("requestsPosted");
                      Menu menu = navigationView.getMenu();
                      MenuItem requests_posted = menu.findItem(R.id.requests_posted_counter);
                      requests_posted.setTitle(requestsPostedCounter);
  
                      MenuItem requests_accepted = menu.findItem(R.id.requests_accepted_counter);
                      requests_accepted.setTitle(requestAcceptedCounter);
                  }
  
                  @Override
                  public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                      newRequestAcceptedCounter = (Map&lt;String, String&gt;) dataSnapshot.getValue();
                      String requestAcceptedCounter = newRequestAcceptedCounter.get("requestsAccepted");
                      String requestsPostedCounter = newRequestAcceptedCounter.get("requestsPosted");
                      Menu menu = navigationView.getMenu();
                      MenuItem requests_posted = menu.findItem(R.id.requests_posted_counter);
                      requests_posted.setTitle(requestsPostedCounter);
  
                      MenuItem requests_accepted = menu.findItem(R.id.requests_accepted_counter);
                      requests_accepted.setTitle(requestAcceptedCounter);
                  }
  
                  @Override
                  public void onChildRemoved(DataSnapshot dataSnapshot) {
  
                  }
  
                  @Override
                  public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
                  }
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
  
                  }
              });
          }
  </code></pre>
  
  <p>What's going wrong here?</p>
  
  <p>Please let me know.</p>