title: Get values from the Datasnapshot object with keys in Firebase Android
body: <p>I want to print some data after getting from the <code>DataSnapShot</code> object. For printing it, I am doing in this way;</p>
  
  <pre><code>private void getUpdates(DataSnapshot DS){
      for(DataSnapshot mydata:DS.getChildren()){
       Log.i("", String.valueOf(data));
      }
  }
  </code></pre>
  
  <p>and making <code>firebase</code> instance as;</p>
  
  <pre><code>       FirebaseDatabase database = FirebaseDatabase.getInstance();
          myRef = database.getReference("myDB");
          myRef.addChildEventListener(new ChildEventListener() {
              @Override
              public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                  getUpdates(dataSnapshot);
              }
  
              @Override
              public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                  getUpdates(dataSnapshot);
              }
  </code></pre>
  
  <p>Printing as:</p>
  
  <pre><code> DataSnapshot { key = areaName, value = myName1}
      DataSnapshot { key = decs, value =  desc1}
      DataSnapshot { key = areaName, value = myName2 }
      DataSnapshot { key = desc, value = desc2 }
  </code></pre>
  
  <p>But <strong>I want to get only <code>desc</code> values.</strong> </p>
  
  <p>My Model class is:</p>
  
  <pre><code>public class Singleton {
      private String areaName;
      private String desc;
  
  
      public Singleton(String areaName, String desc) {
          this.areaName = areaName;
          this.desc = desc;
      }
  
      public String getAreaName() {
          return areaName;
      }
  
      public void setAreaName(String areaName) {
          this.areaName = areaName;
      }
  
      public String getDesc() {
          return desc;
      }
  
      public void setDesc(String desc) {
          this.desc = desc;
      }
  
  
  
  }
  </code></pre>
  
  <p>I tried in this way;</p>
  
  <pre><code>String decsrip= (String) mydata.child("desc").getValue();
  Log.i("", decsrip);
  </code></pre>
  
  <p>But it is printing</p>
  
  <pre><code>null
  </code></pre>
  
  <p>Then I tried as</p>
  
  <pre><code>Map&lt;String, Object&gt; map = (Map&lt;String, Object&gt;) mydata.getValue();
  String descrip = (String) map.get("desc");
  Log.i("",descrip );
  </code></pre>
  
  <p>The application crashed by saying</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map</p>
  </blockquote>
  
  <p>Where the data is? Can I get the value of <code>desc</code> only?</p>