title: error while ds.child(key).setValue() into children
body: <p>I want to sum up the &quot;monthamt&quot; inside a key if &quot;month&quot; is equal to the month on Firebase. When I run this code, it appears to be:
  <a href="https://i.stack.imgur.com/P2uAu.png" rel="nofollow noreferrer">Firebase for Summary</a></p>
  <p>I have update my complete code as below.</p>
  <p>The code to sum up the &quot;monthamt&quot;, I have no idea how to direct it to the key:</p>
  <pre><code>final String key = ds.push().getKey();
                      ds.orderByKey().addListenerForSingleValueEvent(new ValueEventListener() {
                          @Override
                          public void onDataChange(DataSnapshot dataSnapshot) {
                              if (dataSnapshot.exists()) {
                                  ds.addChildEventListener(new ChildEventListener() {
                                      @Override
                                      public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
                                          Calendar c = Calendar.getInstance();
                                          SimpleDateFormat format = new SimpleDateFormat(&quot;ddMMyy&quot;);
                                          SimpleDateFormat fm = new SimpleDateFormat(&quot;MM&quot;);
                                          String month = (String) dataSnapshot.child(&quot;month&quot;).getValue();
                                          //testing
                                          double value = Double.valueOf(String.valueOf(dataSnapshot.child(&quot;amt&quot;).getValue()));
                                          double mvalue = Double.valueOf(String.valueOf(dataSnapshot.child(&quot;monthamt&quot;).getValue()));
                                              value = roundOff(value);
                                              mvalue = roundOff(mvalue);
  
                                          if (fm.format(c.getTime()).equals(month)) {
                                              String key1 = dataSnapshot.getKey();
                                              ds.child(&quot;-MJMXp5Obhsd68HMrWax&quot;).child(&quot;monthamt&quot;).setValue(roundOff(mvalue + amt) + &quot;&quot;);
                                                  Toast.makeText(newTransaction.this, &quot;ok&quot;, Toast.LENGTH_SHORT).show();
                                          } else {
                                              Calendar b = Calendar.getInstance();
                                              ds.child(key).child(&quot;date&quot;).setValue(format.format(b.getTime()));
                                              ds.child(key).child(&quot;amt&quot;).setValue(amt + &quot;&quot;);
                                              ds.child(key).child(&quot;month&quot;).setValue(fm.format(b.getTime()));
                                              ds.child(key).child(&quot;monthamt&quot;).setValue(amt + &quot;&quot;);
                                              ds.child(key).child(&quot;trans&quot;).setValue(&quot;1&quot;);
                                              dt.child(&quot;Bill&quot;).child(k).child(&quot;gtranid&quot;).setValue(&quot;1&quot;);
                                              Toast.makeText(newTransaction.this,month, Toast.LENGTH_SHORT).show();
                                          }
                                      }
  
                                      @Override
                                      public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
  
                                      }
  
                                      @Override
                                      public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {
  
                                      }
  
                                      @Override
                                      public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
  
                                      }
  
                                      @Override
                                      public void onCancelled(@NonNull DatabaseError databaseError) {
  
                                      }
                                  });
  
                              } else {
                                  Calendar c = Calendar.getInstance();
                                  SimpleDateFormat format = new SimpleDateFormat(&quot;ddMMyy&quot;);
                                  SimpleDateFormat fm = new SimpleDateFormat(&quot;MM&quot;);
                                  ds.child(key).child(&quot;date&quot;).setValue(format.format(c.getTime()));
                                  ds.child(key).child(&quot;amt&quot;).setValue(amt + &quot;&quot;);
                                  ds.child(key).child(&quot;month&quot;).setValue(fm.format(c.getTime()));
                                  ds.child(key).child(&quot;monthamt&quot;).setValue(amt + &quot;&quot;);
                                  ds.child(key).child(&quot;trans&quot;).setValue(&quot;1&quot;);
                                  dt.child(&quot;Bill&quot;).child(k).child(&quot;gtranid&quot;).setValue(&quot;1&quot;);
                              }
                          }
  </code></pre>