create account

Firebase Cloud Storage | Android App Development | Lecture#59 | Hive Learners by faisalamin

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

Dear Hive Learners, In the previous lecture we learn how to get the Profile Image in an Image View. Today we will configure the FirebaseStorage so that we can save this image in our Firebase storage when the user signup. We will save the link to the image in our real-time database. When we successfully upload an image to Firebase Storage we will get a link to access the image.

![](https://images.ecency.com/DQmYc14xumFXwc9eRKZT88sTESmbjXeQ2T5FonwmKHhyyZW/multi_purpose_7_.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 add Firebase Cloud Storage to our peoject

## Assignment

- Configure Firebase Cloud SDK to your project

## Procedure

First of all, we need to open the Firebase Assistance. This will help us to implement the dependencies in one click. Open the Cloud Storage section and connect your app to Firebase and click on ``` Add the Cloud storage SDK to your app```. This will implement the dependencies and sync the project. Wait for the project to sync successfully.


![](https://images.ecency.com/DQmUM5Kud3JV68vMmgH7PpTaBEA7kkb5zMfT5jWo2YuwBz6/image.png)

Click on Accept Changes.

![](https://images.ecency.com/DQmUBpc6fSbMiuRRBJMrBdpQpq5fN7kBk7CQxLgfUbnST6N/image.png)

Now declare and initialize the Firebase Storage and the Storage Reference variables.


```
    private FirebaseStorage storage = FirebaseStorage.getInstance();
    private StorageReference storageRef = storage.getReference();
```

![](https://images.ecency.com/DQmcKWX7QrMAjyNy1EXZrKANxngqteGqXXozSFQqB8PYhwt/image.png)

Now we can use this storage reference to save the images in a child. Let's name it ```profile_images```. We can implement the On Complete Listener and this time I am using null in place of File Uri as we do not pick the Uri yet.

```
 storageRef.child("profile_images").putFile(null).addOnCompleteListener(task -> {


        });
```

![](https://images.ecency.com/DQmZoNVvu9HVFqiaiMCPHqNJUENTnwpNVAKREd9aV4w6jcQ/image.png)

We can show the Progressbar when the file is uploading and cancel if the task is failed or successful.

```
storageRef.child("profile_images").putFile(null).addOnCompleteListener(task -> {
            progressDialog.setMessage("Please wait...");
            progressDialog.show();
            progressDialog.setCancelable(false);

            if (task.isSuccessful()) {
                if (progressDialog.isShowing()) {
                    progressDialog.cancel();
                    Toast.makeText(this, "Uploaded", Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
                if (progressDialog.isShowing()) {
                    progressDialog.cancel();
                }
            }


        });
```

![](https://images.ecency.com/DQmcp1s1h5bcqvjHe6xu8V7WzYWfKhhgMN9fofexfkQPBsJ/image.png)

In the next lecture, we will create a function upload_image with the parameter Uril. This function will accept the Uri where is called. In the Activity result method, we will call save the Uri in a variable,, and on the profile creation time we can set the Uri in his function or we can use this Uri for the UserProfileChangeRequest.</div>

<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 159 others
properties (23)
authorfaisalamin
permlinkfirebase-cloud-storage-or-android
categoryhive-153850
json_metadata"{"links": ["https://github.com/faisalamin9696/HiveLearners2", "https://discord.gg/7Bzqv4qUMT"], "image": ["https://images.ecency.com/DQmYc14xumFXwc9eRKZT88sTESmbjXeQ2T5FonwmKHhyyZW/multi_purpose_7_.png", "https://images.ecency.com/DQmUM5Kud3JV68vMmgH7PpTaBEA7kkb5zMfT5jWo2YuwBz6/image.png", "https://images.ecency.com/DQmUBpc6fSbMiuRRBJMrBdpQpq5fN7kBk7CQxLgfUbnST6N/image.png", "https://images.ecency.com/DQmcKWX7QrMAjyNy1EXZrKANxngqteGqXXozSFQqB8PYhwt/image.png", "https://images.ecency.com/DQmZoNVvu9HVFqiaiMCPHqNJUENTnwpNVAKREd9aV4w6jcQ/image.png", "https://images.ecency.com/DQmcp1s1h5bcqvjHe6xu8V7WzYWfKhhgMN9fofexfkQPBsJ/image.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"], "thumbnails": ["https://images.ecency.com/DQmYc14xumFXwc9eRKZT88sTESmbjXeQ2T5FonwmKHhyyZW/multi_purpose_7_.png", "https://images.ecency.com/DQmUM5Kud3JV68vMmgH7PpTaBEA7kkb5zMfT5jWo2YuwBz6/image.png", "https://images.ecency.com/DQmUBpc6fSbMiuRRBJMrBdpQpq5fN7kBk7CQxLgfUbnST6N/image.png", "https://images.ecency.com/DQmcKWX7QrMAjyNy1EXZrKANxngqteGqXXozSFQqB8PYhwt/image.png", "https://images.ecency.com/DQmZoNVvu9HVFqiaiMCPHqNJUENTnwpNVAKREd9aV4w6jcQ/image.png", "https://images.ecency.com/DQmcp1s1h5bcqvjHe6xu8V7WzYWfKhhgMN9fofexfkQPBsJ/image.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"], "tags": ["hive-153850", "stem", "education", "pakistan", "development", "programming", "firebase", "android", "firebasestorage"], "description": "", "app": "ecency/3.0.26-vision", "format": "markdown+html"}"
created2022-08-29 14:50:33
last_update2022-08-29 14:50:33
depth0
children2
last_payout2022-09-05 14:50:33
cashout_time1969-12-31 23:59:59
total_payout_value10.453 HBD
curator_payout_value10.393 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,899
author_reputation104,701,778,605,493
root_title"Firebase Cloud Storage | Android App Development | Lecture#59 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,140,919
net_rshares29,519,721,123,056
author_curate_reward""
vote details (223)
@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-2022829t175255761z
categoryhive-153850
json_metadata{"tags":["ecency"],"app":"ecency/3.0.20-welcome","format":"markdown+html"}
created2022-08-29 17:52:57
last_update2022-08-29 17:52:57
depth1
children0
last_payout2022-09-05 17:52:57
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"Firebase Cloud Storage | Android App Development | Lecture#59 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,145,412
net_rshares0
@stemsocial ·
re-faisalamin-firebase-cloud-storage-or-android-20220830t035430233z
<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-firebase-cloud-storage-or-android-20220830t035430233z
categoryhive-153850
json_metadata{"app":"STEMsocial"}
created2022-08-30 03:54:30
last_update2022-08-30 03:54:30
depth1
children0
last_payout2022-09-06 03:54:30
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"Firebase Cloud Storage | Android App Development | Lecture#59 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id116,157,898
net_rshares0