I want to update the date on Firebase on a specific node.
DB Structure:
I am trying as
private void updateData() {
database = FirebaseDatabase.getInstance();
myref = database.getReference();
myref.child("myDb").child("awais@gmailcom").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
dataSnapshot.getRef().child("leftSpace").setValue(newValue);
dialog.dismiss();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d("User", databaseError.getMessage());
}
});
}
I want to update the leftSpace
key with the value of newValue
, newValue
is the type of string here. But it is not updating the value in Firebase.
If I give here
dataSnapshot.getRef().child("leftSpace").setValue(765);
it updates well. But I want to update in the format of string on the Firebase.
I saved the data on Firebase of all string types. (My pattern class contains all of the type strings)
Why it is not updating the newvalue
of type string here?
Edit 1 Suggested by @Rjz Satvara
You method is adding a new node under myDB
as
It is not updating the already one.
you can assign new value in same child,like
According to Firebase Official Documentation you can update the specific node of parent node in this way
Note! TABLE_NAME mean your parent node whose child node you want to update.
In Firebase To update specific value you can use it...
or you can move into child using "/" as follow :