Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Updated 27 December 2019
Firebase storage provides facility to upload any file like image, video, audio, etc without using server side code.
In this blog, I’ll explain how to create in android application a feature that allows users to upload local image to firebase storage and download the list from the images with the help of firebase database with an example.
Our example app lets user enter file name in a text field and upload image.
Step 1. Create a new project on android studio or open an existing project in which you want to add firebase storage.
Step 2. Add the firebase to the project, follow this link to setup firebase to project. Link: https://firebase.google.com/docs/android/setup
Step 3. Add these dependency to the build.gradle(app)
Step 4. Add the permission to the Androidmanifest.xml
1. Firstly image is selected from gallery using file chooser and displayed in ImageView.
2. Before using firebase we have to get its instance and then using the instance create reference to firebase storage app. It can be done by following code.
3. Now a child reference is created and using it we call putFile() method to upload image to firebase storage.
4. If image is uploaded successfully then success message is shown otherwise error is shown in toast.
5. To upload the image url to firebase database.
After Getting the image from the application we are now calling then uploadFile() method defined in the main activity to upload image to firebase storage.
In this firstly we are creating a child on the storage and using the that child reference to upload the image to firebase storage using putFile(imageUri!!). To get Success, failure and progress we using
after successfully uploading the file to firebase storage we will be uploading the image url to the firebase database to do that we getting the name from the editText and image from the fileReference downloadurl and saving it to the firebase database by calling uploadFileToDatabase.
Create a class having name as ImagesActivity.kt : In this activity we are getting all the list of images saved in the firebase database.
. . . . . . .
That’s all for now, I hope this blog have helped you, Comment below if you have any queries related to above android upload image to firebase storage example.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.