title: Retrieving data from nested nodes in Firebase Database
body: <p>This is my database structure:</p>
  
  <p><img src="https://i.stack.imgur.com/2DpP2.png" alt="enter image description here"></p>
  
  <p>All the children of the Request node are timestamps. For a particular timestamp, within the product node, i want to retrieve all the values of the object productName. And then arrange them so that it is composed as the body of an email. The part where i am stuck at is in fetching the data of productName.</p>
  
  <p>So far i've been able to fetch the data of the total in the second node. the code i'm using is this:</p>
  
  <pre><code>    DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Requests");
  ref.addListenerForSingleValueEvent(new ValueEventListener() {
      @Override
      public void onDataChange(DataSnapshot dataSnapshot) {
          collectProducts((Map&lt;String, Object&gt;) dataSnapshot.getValue());
      }
  
      @Override
      public void onCancelled(DatabaseError databaseError) {
  
      }
  });
  
  
  
  private void collectProducts(Map&lt;String, Object&gt; value) {
  
      ArrayList&lt;String&gt; products = new ArrayList&lt;&gt;();
      for (Map.Entry&lt;String, Object&gt; entry : value.entrySet()){
          Map singleUser = (Map) entry.getValue();
          products.add((String) singleUser.get("total"));
      }
  
      Intent emailIntent = new Intent(Intent.ACTION_SEND);
      emailIntent.setType("plain/text");
      emailIntent.putExtra(Intent.EXTRA_EMAIL, "example@gmail.com");
  
      StringBuilder sb = new StringBuilder();
      for (String s : products) {
          sb.append(s);
          sb.append("\n");
      }
      emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
  
      try {
          startActivity(Intent.createChooser(emailIntent, "Send mail..."));
          Log.i("Email sent!", "");
      } catch (android.content.ActivityNotFoundException ex) {
          Toast.makeText(Cart.this,
                  "There are no email clients installed.", Toast.LENGTH_SHORT).show();
      }
  
  }
  </code></pre>
  
  <p>But no luck with getting productName.</p>
  
  <p>I am new to Android and Firebase. Any help is appreciated.</p>