Updating the data on Firebase Android

firebase update specific field android
retrieve multiple data from firebase android
how to update values in firebase android
updatechildren firebase android
how to retrieve data from firebase in android studio
firebase get data by key android
firebase save data android
retrieve data from firebase android

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() {
    public void onDataChange(DataSnapshot dataSnapshot) {


    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


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.

In Firebase To update specific value you can use it...

     try {
        } catch (Exception e) {

Saving Data, We've seen how to create and retrieve data from our Firebase database using some simple code to populate our A Practical Guide to Firebase on Android  A simple getting started guide to Firebase Database, a NoSQL database with a rich client side API. We’ve seen how to create and retrieve data from our Firebase database using some simple code to populate our database with a bunch of salads. So now we will create a shopping cart for our users to demonstrate updating and deleting data in realtime.

you can assign new value in same child,like

  Firebase firebase = new Firebase("your database link/myDb");

Updating the data on Firebase Android, Firebase Realtime Database Update and Delete with What is Firebase, Features, Android Studio, Assistance, Adding Firebase to App, Installation, Data,  Java Code to update data in firbase database Android updatechildren method is used to update the data in firebase and completion listeners is used which notify when data is updated and it is one of the important method and helps in keeping synchronization for further operations (CRUD).

According to Firebase Official Documentation you can update the specific node of parent node in this way

Using setValue() in this way overwrites data at the specified location, including any child nodes. However, you can still update a child without rewriting the entire object. If you want to allow users to update their profiles you could update the username as follows:

    FirebaseDatabase  database = FirebaseDatabase.getInstance();
    DatabaseReference mDatabaseRef = database.getReference();


Note! TABLE_NAME mean your parent node whose child node you want to update.

Firebase Realtime Database Tutorial for Android, You can read the individual changelogs for details (Android, iOS, web), getKey​(); // Create the data we want to update Map newPost = new  How to update data in Android Cloud FireStore Database Imagine when we covered how to add data to android cloud Firestore database we realized that we have added a wrong data. Beside that, may be our application is design in such a way that some user actions can trigger changes to data in our cloud Firestore database.

Firebase Android Tutorial [4/5] : Update and Delete Realtime Data , Updating and Deleting From Your Firebase Database Learn how to update and delete data in real time in a Firebase database when developing Firebase mobile apps for Android. by

Firebase Realtime Database Tutorial for Android || Update data in , Firebase data is written to a FirebaseDatabase reference and retrieved by attaching an asynchronous listener to the reference. The listener is triggered once for the initial state of the data and again anytime the data changes.

#3 Firestore Android Tutorial - Updating Data, Set the data of a document within a collection, explicitly specifying a document identifier. Add a new document to a collection. In this case, Cloud Firestore automatically generates the document

  • Not working. it is making a new node. See the Edit 1 in question.
  • Still not working. It is adding a new node of name leftSpace under the myDb node. (myDb is my DB name). See where I am . I run the code as myref.child("CarParki").child("awais@gmailcom").addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { try { myref.child("awais@gmailcom").child("leftSpace").setValue("YourDateHere"); } catch (Exception e) { e.printStackTrace(); }
  • yup.. congratulation and thank you.. happy Sharing , keep learning and Enjoy
  • You can pass the entire path as one string. So this shorter code accomplishes the same: ref.child("myDb/awais@gmailcom/leftSpace").setValue("YourDateHere");