create account

Edit Profile Data | Android App Development | Lecture#65 | Hive Learners by faisalamin

View this thread on: hive.blogpeakd.comecency.com
· @faisalamin ·
$9.70
Edit Profile Data | Android App Development | Lecture#65 | Hive Learners
<center><h2>𝓖𝓻𝓮𝓮𝓽𝓲𝓷𝓰𝓼</h2></center>
<div class="text-justify">


Hello, dear Hive Learners, I hope you all are well. In the previous lecture, we load an image from Firebase URL to an image view using a Library Glide. We learn how to implement the Glide Library in the Gradle dependencies and also learn what is Glide library and how to use it. Today we will learn how to edit the profile data in firebase by using the Firebase user UserProfileChangeRequest. So let's get started.

![multi purpose (11).png](https://files.peakd.com/file/peakd-hive/faisalamin/23xpVuR2EATqXdBVcHxHUu1TnuoTDsv9o85whv7isQjpKy4deXaWMHPKs2qmvoBuh4ioH.png)

## [GitHub Link](https://github.com/faisalamin9696/HiveLearners2)

Use this GitHub project to clone into your directory. The following lecture will update it so you will never miss the latest code. Happy Coding!

## What Should I Learn

- How to update Profile data

## Assignment

- Update your profile data

## Procedure

First, we need to change the username TextViews to Edittext on the Profile Page. We can keep them disabled until an edit button clicks. On the edit button click, we enable all the EditText and the ImageView so that the user can change the data inside the EditTexts. We can not change the email so leave it as TextView.



![image.png](https://files.peakd.com/file/peakd-hive/faisalamin/23w2exkfM5v8rFwGi1xFzPSoPrtaSVGBXuyoFXLM38MGbFnxp7NrTCJ4xAaaQ7EZKmY8r.png)

Now we create two functions to enable and disable the Edit State.

```
 private void disableEdit() {
        profile_image.setEnabled(false);
        username_tv.setEnabled(false);
    }

    private void enableEdit() {
        profile_image.setEnabled(true);
        username_tv.setEnabled(true);
    }
```


![image.png](https://files.peakd.com/file/peakd-hive/faisalamin/23t79QFTodP7E4DvkArBmFNt6kVbRB6NCdRCZL2qxdwgm5KHtTKjAwXB7jfhYoaszfJuC.png)

Create a button in the Profile Page that we will use to edit and save the edited data,


![image.png](https://files.peakd.com/file/peakd-hive/faisalamin/23w2ekhAAc1WShmu7NmtyunFX4UEH5tcegZ9fJiLQ7frhVFmkPavS4iWtmdLYFFXxHSpB.png)

Declare and initialize this editProfile_btn and add the click listener and enable the edit state on click and change the button text to ```UPDATE```. We will use the same button to enable the edited state and to update the data.


![image.png](https://files.peakd.com/file/peakd-hive/faisalamin/23t78ndX1i7C3W1Gm3rPgqb63AYBP9aR7pdzdh4beNVAvv59TGRNvbhiU65S29wvpdrvc.png)


In updation we need to check if the profile image is updated or not. There will be two conditions now with the new profile image upload and one with the previous link. Here I implement all the methods and complete the code.</div>


```
private void updateProfile(String username) {

        if (firebaseAuth.getCurrentUser().getPhotoUrl() == profileImageUri) {
            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
            UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
                    .setDisplayName(username)
                    .setPhotoUri(profileImageDownloadUri)
                    .build();
            assert user != null;
            user.updateProfile(profileUpdates).addOnCompleteListener(task2 -> {
                if (task2.isSuccessful()) {
                    if (progressDialog.isShowing()) {
                        progressDialog.cancel();
                    }
                    Toast.makeText(this, "Updated Successfully", Toast.LENGTH_SHORT).show();
                    disableEdit();


                } else {
                    Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();

                }

            });

        } else {
            upload_image_updateUser(username);
        }
    }
```

![image.png](https://files.peakd.com/file/peakd-hive/faisalamin/23t7BByk1WjXJVs8MHqWamu2fLgh4sF2kXkkyhQv2NuAjbM2VbZLRPNqmQtznaHbRJPBZ.png)


<center>
![hl_divider.png](https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png)

<h2>Thank You</h2>

![hl_footer_banner.png](https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png)
<div class="pull-left"><a href="https://discord.gg/7Bzqv4qUMT">
<img src="https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"/></a>
</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 163 others
👎  , ,
properties (23)
authorfaisalamin
permlinkedit-profile-data-or-android-app-development-or-lecture65-or-hive-learners
categoryhive-153850
json_metadata{"app":"peakd/2022.07.1","format":"markdown","tags":["stem","android","ocd","blocktrade","development","coding","java","firebase","pakistan","diy"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/faisalamin/23xpVuR2EATqXdBVcHxHUu1TnuoTDsv9o85whv7isQjpKy4deXaWMHPKs2qmvoBuh4ioH.png","https://files.peakd.com/file/peakd-hive/faisalamin/23w2exkfM5v8rFwGi1xFzPSoPrtaSVGBXuyoFXLM38MGbFnxp7NrTCJ4xAaaQ7EZKmY8r.png","https://files.peakd.com/file/peakd-hive/faisalamin/23t79QFTodP7E4DvkArBmFNt6kVbRB6NCdRCZL2qxdwgm5KHtTKjAwXB7jfhYoaszfJuC.png","https://files.peakd.com/file/peakd-hive/faisalamin/23w2ekhAAc1WShmu7NmtyunFX4UEH5tcegZ9fJiLQ7frhVFmkPavS4iWtmdLYFFXxHSpB.png","https://files.peakd.com/file/peakd-hive/faisalamin/23t78ndX1i7C3W1Gm3rPgqb63AYBP9aR7pdzdh4beNVAvv59TGRNvbhiU65S29wvpdrvc.png","https://files.peakd.com/file/peakd-hive/faisalamin/23t7BByk1WjXJVs8MHqWamu2fLgh4sF2kXkkyhQv2NuAjbM2VbZLRPNqmQtznaHbRJPBZ.png","https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png","https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png","https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"]}
created2022-09-05 16:30:39
last_update2022-09-05 16:30:39
depth0
children7
last_payout2022-09-12 16:30:39
cashout_time1969-12-31 23:59:59
total_payout_value4.874 HBD
curator_payout_value4.829 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,368
author_reputation104,701,778,605,493
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,342,565
net_rshares13,057,003,616,986
author_curate_reward""
vote details (230)
@curation-cartel ·
![1UP-PIZZA.png](https://files.peakd.com/file/peakd-hive/curation-cartel/23xediR4hotaNsS5pUJrmYVg3YGeTLpui41uCij2jhUDZ4uFT84zoGJf8a8VnfELXLJgt.png) |  <div class="phishy"><u><h4>You have received a __1UP__ from @gwajnberg!</h4></u></div> The @oneup-cartel will soon upvote you with:<hr> __@stem-curator__ <hr>_And they will bring !PIZZA 🍕._
-|-

<sup>[Learn more](https://peakd.com/hive-102223/@flauwy/the-curation-cartel-1up-trigger-smart-voting-mana-and-high-delegation-returns-for-14-different-tribes) about our delegation service to earn daily rewards. Join the Cartel on [Discord](https://discord.gg/mvtAneE3Ca).</sup>
properties (22)
authorcuration-cartel
permlinkre-edit-profile-data-or-android-app-development-or-lecture65-or-hive-learners-20220906t202133z
categoryhive-153850
json_metadata"{"app": "beem/0.24.26"}"
created2022-09-06 20:21:33
last_update2022-09-06 20:21:33
depth1
children0
last_payout2022-09-13 20:21:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length623
author_reputation1,123,882,653,763
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,376,355
net_rshares0
@dirolls ·
!PIZZA
!PGM
!LUV
!BEER
properties (22)
authordirolls
permlinkre-faisalamin-rhun6a
categoryhive-153850
json_metadata{"tags":["hive-153850"],"app":"peakd/2022.07.1"}
created2022-09-07 16:59:00
last_update2022-09-07 16:59:00
depth1
children0
last_payout2022-09-14 16:59:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation10,190,203,523
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,401,447
net_rshares0
@ecency ·
**Yay!** 🤗<br>Your content has been **boosted with Ecency Points**, by @faisalamin. <br>Use Ecency daily to boost your growth on platform! <br><br><b>Support Ecency</b><br>[Vote for new Proposal](https://hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B197%5D&approve=true)<br>[Delegate HP and earn more](https://ecency.com/hive-125125/@ecency/daily-100-curation-rewards)
properties (22)
authorecency
permlinkre-202296t03657891z
categoryhive-153850
json_metadata{"tags":["ecency"],"app":"ecency/3.0.20-welcome","format":"markdown+html"}
created2022-09-06 00:37:00
last_update2022-09-06 00:37:00
depth1
children0
last_payout2022-09-13 00:37:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length380
author_reputation624,422,971,962,054
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,353,942
net_rshares0
@gwajnberg ·
That is another important part of the app right? allowing the update of profile, I have already seen lots of bugs around in this part of the app.
!1UP
<a href="https://discord.gg/zQrvxAu7mu">
<img src="https://files.peakd.com/file/peakd-hive/thecuriousfool/23wCNFDyCLJu1v77TTg2MYKkd7XWkgF9fhiLujTDAaLaUz7H4AaQkDentB5UMVS8FcrVs.png"></a>
properties (22)
authorgwajnberg
permlinkrht1ug
categoryhive-153850
json_metadata{"tags":["stem"],"image":["https://files.peakd.com/file/peakd-hive/thecuriousfool/23wCNFDyCLJu1v77TTg2MYKkd7XWkgF9fhiLujTDAaLaUz7H4AaQkDentB5UMVS8FcrVs.png"],"links":["https://discord.gg/zQrvxAu7mu"],"app":"stemgeeks/0.1","canonical_url":"https://stemgeeks.net/@gwajnberg/rht1ug"}
created2022-09-06 20:20:39
last_update2022-09-06 20:20:39
depth1
children1
last_payout2022-09-13 20:20:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length336
author_reputation380,116,414,843,647
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,376,336
net_rshares0
@faisalamin ·
Yes, Thank you. We will fix the bugs together
properties (22)
authorfaisalamin
permlinkre-gwajnberg-202297t6242883z
categoryhive-153850
json_metadata{"tags":["stem"],"app":"ecency/3.0.33-mobile","format":"markdown+html"}
created2022-09-07 01:24:03
last_update2022-09-07 01:24:03
depth2
children0
last_payout2022-09-14 01:24:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length45
author_reputation104,701,778,605,493
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,382,674
net_rshares0
@pizzabot ·
<center>PIZZA! 


PIZZA Holders sent <strong>$PIZZA</strong> tips in this post's comments:
@dirolls<sub>(7/15)</sub> tipped @faisalamin (x1)


<sub>Learn more at https://hive.pizza.</sub></center>
properties (22)
authorpizzabot
permlinkre-edit-profile-data-or-android-app-development-or-lecture65-or-hive-learners-20220907t170010z
categoryhive-153850
json_metadata"{"app": "beem/0.24.19"}"
created2022-09-07 17:00:09
last_update2022-09-07 17:00:09
depth1
children0
last_payout2022-09-14 17:00:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length196
author_reputation7,617,921,360,686
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,401,477
net_rshares0
@stemsocial ·
re-faisalamin-edit-profile-data-or-android-app-development-or-lecture65-or-hive-learners-20220907t063642100z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-faisalamin-edit-profile-data-or-android-app-development-or-lecture65-or-hive-learners-20220907t063642100z
categoryhive-153850
json_metadata{"app":"STEMsocial"}
created2022-09-07 06:36:42
last_update2022-09-07 06:36:42
depth1
children0
last_payout2022-09-14 06:36:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,927,767,309,334
root_title"Edit Profile Data | Android App Development | Lecture#65 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,388,024
net_rshares0