Change firebase sibling value

Anas Baligh :

I have firebase real-time database

enter image description here

I need to change sibling value using symptomName node.

I have tried the following:

  symptomssDatabase.child(symptomssDatabase.getKey()).child("count").setValue("0");
Peter Haddad :

To change the value of count try the following:

FirebaseDatabase.getInstance().getReference().child("Symptoms").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                String key = ds.getKey();
                FirebaseDatabase.getInstance().getReference().child("Symptoms").child(key).child("count").setValue("0");
            }
        }
            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });

You need to iterate to be able to get the key that is above child node count

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=151038&siteId=1