Firebase Update Data in Android – 2020

by | Feb 25, 2020 | Android, Android Firebase Tutorials, Android for Beginners, Basics, Bull's Rent, Database | 0 comments

In this tutorial, we are going to update the data of firebase in the android studio.

Previously, we have designed our profile screen and then store values in the firebase.

Subsequently, we retrieve data from the firebase.

Now we have to update that stored data.

The modification of data that is already present in the database is called an update of data.

Update data is the most important function in any application.

If a human error or any error occurs in saving or storing data, then we have to update that data.

Subscribe us on Youtube

To make an update in the first place we have to get the data from the database and then update it.

Similarly to get the data we have to make an activity the same as profile activity.

So now let’s get started.

Steps to Update data in firebase:

To create a profile screen we have to do the following steps.

  1. Design an activity
  2. Make the onClick method.
  3. Write code in onClick function.
  4. Update data in firebase.

1- Design an activity for update data in firebase

In the first place, we have to design a new activity to update data.

In this case, we have already designed a profile page in which we retrieve data from the firebase.

Therefore we recommend you to view our tutorials of profile screen design and retrieve data to design the activity to update data.

2- Make onClick Method

Hence after creating the activity and retrieve data from firebase.we have to update data in firebase when the update button clicked.

Thus we have to make an “onClick” function because we want to update data when the update button will click.

So for that, open XML file named as activity_user_profile.xml

Now in the design, click on the update button. go to attributes on the right side of the screen. Search for onClick.

After that write the name of the method as update as shown in the picture.

This will appear as red but don’t be worry, because we haven’t created a method yet.

To remove that error go to make a function named as update having attribute of View as shown in the code below.

public void update(View view){

Now you will see that the error is gone.

3- Write code in onClick method

As we have already retrieve data from firebase so we will use the same variables for further use.

Now in the update function, we will update data only if the name or password is changed.

You can also add anything you want but in this case, we will only apply the check on name and password changed.

So for that make two functions named as isNameChanged() and isPasswordChanged() with return type Boolean.

4- Update Data in firebase.

To update data in firebase, Above all we have to refer to our firebase database.

Therefore make a global variable of reference. and assign the root to it. In our case, the root is “users” so our code will be.

reference = FirebaseDatabase.getInstance().getReference("users");

Earlier we have created 2 functions to check if the data is changed Now write the code in it.

like that if the name or password changed then data will update otherwise it shows that data is the same. As shown in the code below.

private boolean isPasswordChanged(){
        return true;
        return false;
private boolean isNameChanged(){
        return true;
        return false;


Get Complete Source code for Bull’s Rent App


🚀 Supercharge your Flutter skills! Subscribe to my YouTube channel now for mind-blowing coding insights, expert tips, and exclusive content. Don’t miss out!


Android firebase app - android app 2022 - firebase android app - bulls rent app - coding with t app - android app
android complete login signup product by taimoor sikander free for any type of android app
Flutter E Commerce App Modern and latest
Flutter Login App UI Source Code - Flutter Complete App - Flutter App Design - Flutter App 2023 - Complete Flutter App 2023
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Latest Tutorial

How to create a Custom Appbar in flutter. Custom Appbar Design. Flutter App Design
How to create a Custom Shape in Flutter. Flutter E Commerce app Design. Ecommerce app design Flutter. Flutter clippath tutorial
Bottom Navigation bar in Flutter. Flutter Material 3 bottom navigation bar. How to design background color of Flutter bottom navigation bar. Flutter ecommerce app design