title: Refresh ListView after update Child Firebase
body: <p>I have this on Firebase:
  <a href="https://i.stack.imgur.com/60uFZ.png" rel="nofollow noreferrer">Firebase data</a></p>
  <p>And some other foods under with the same structure. I Just created this Aaaa to make tests.</p>
  <p>The fact is that I can list in <code>listview</code> all this foods and when I <code>longclick</code> any item It opens an <code>AlertDialog</code> that I can edit or delete any item (when add/deleted the <code>listview</code> is updated). But after editing &quot;base&quot;, &quot;carboidrato&quot; and etc, when I select the item, the old value is still displayed.</p>
  <p>I tried with <code>adapter.notifyDataSetChanged();</code> in ALL places but no success. In log and in Firebase I can see the child is updated.</p>
  <pre><code>listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
              @Override
              public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  Alimentos alimento = list.get(position);
                  showUpdateDeleteDialog(alimento);
                  return true;
              }
          });
  </code></pre>
  <pre><code> private void showUpdateDeleteDialog(final Alimentos alimento) {
          AlertDialog.Builder dialogBuilder2 = new AlertDialog.Builder(this);
          LayoutInflater inflater2 = getLayoutInflater();
          final View dialogView2 = inflater2.inflate(R.layout.update_dialog, null);
          dialogBuilder2.setView(dialogView2);
  
          buttonDelete = (Button) dialogView2.findViewById(R.id.buttonDelete);
          buttonUpdate = (Button) dialogView2.findViewById(R.id.buttonUpdate);
  
  buttonUpdate.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
   updateAlimento(alimento);
                  adapter.notifyDataSetChanged();
                  b.dismiss();
              }
  
          });
  </code></pre>
  <pre><code>private boolean updateAlimento(final Alimentos alimento) {
  
          final DatabaseReference dU = FirebaseDatabase.getInstance().getReference(&quot;alimentos&quot;).child(String.valueOf(alimento));
  
  
          dU.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  for (DataSnapshot dataSnapshot : snapshot.getChildren()) {
  
  
                      nome = snapshot.getKey();
  
                      dU.child(&quot;base&quot;).setValue(base);
                      dU.child(&quot;calcio&quot;).setValue(calcio);
                      dU.child(&quot;carboidrato&quot;).setValue(carbo);
                      dU.child(&quot;cinzas&quot;).setValue(cinzas);
                      dU.child(&quot;cobre&quot;).setValue(cobre);
                      dU.child(&quot;colesterol&quot;).setValue(colesterol);
                      dU.child(&quot;energiaKJ&quot;).setValue(kcalkj);
                      dU.child(&quot;energiaKcal&quot;).setValue(kcal);
                      dU.child(&quot;ferro&quot;).setValue(ferro);
                      dU.child(&quot;fibraAlimentar&quot;).setValue(fibra);
                      dU.child(&quot;fosforo&quot;).setValue(fosforo);
                      dU.child(&quot;lipideos&quot;).setValue(lip);
                      dU.child(&quot;magnesio&quot;).setValue(magnesio);
                      dU.child(&quot;manganes&quot;).setValue(manganes);
                      dU.child(&quot;niacina&quot;).setValue(niacina);
                      dU.child(&quot;piridoxina&quot;).setValue(piridoxina);
                      dU.child(&quot;potassio&quot;).setValue(potassio);
                      dU.child(&quot;proteina&quot;).setValue(prot);
                      dU.child(&quot;rae&quot;).setValue(rae);
                      dU.child(&quot;re&quot;).setValue(re);
                      dU.child(&quot;retinol&quot;).setValue(retinol);
                      dU.child(&quot;riboflavina&quot;).setValue(riboflavina);
                      dU.child(&quot;sodio&quot;).setValue(sodio);
                      dU.child(&quot;tiamina&quot;).setValue(tiamina);
                      dU.child(&quot;umidade&quot;).setValue(umidade);
                      dU.child(&quot;vitaminaC&quot;).setValue(vit);
                      dU.child(&quot;zinco&quot;).setValue(zinco);
  
                  }
  
              }
  
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
  
          dU.addChildEventListener(new ChildEventListener() {
  
  
              @Override
              public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
  
              }
  
              @Override
              public void onChildChanged(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
  
                  Long changedPost = snapshot.getValue(long.class);
  
  
                  System.out.println(&quot;The updated post title is: &quot; + changedPost);
  
                  Log.i(&quot;TAGBase&quot;, String.valueOf(snapshot.getValue(long.class)));
  
                  
                  listview.invalidateViews();
  
                  adapter.notifyDataSetChanged();
              }
  
              @Override
              public void onChildRemoved(@NonNull DataSnapshot snapshot) {
  
              }
  
              @Override
              public void onChildMoved(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
  
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
  
  
  
          });
  
  
          Toast.makeText(getApplicationContext(), alimento + &quot; atualizado&quot;, Toast.LENGTH_LONG).show();
          return true;
      }
  </code></pre>