Android Display Images from Firebase Storage

Firebase is a backend service which provides various services like database, cloud functions, storage.Cloud Storage for Firebase allows secure cloud storage of files, user generated content like images, audio. Firebase allows easy access of stored files and it can be used to store app content like images and files.

Let’s check how to use Firebase Storage apis to fetch and display image in an ImageView.

Before we jump to android project lets upload some files in the cloud storage. Open firebase dashboard and create storage bucket here.

Open storage rules tab and paste these values

This will make read operations public while only authenticated users would be able to write into the storage bucket.

Upload an image in storage bucket and copy the path as shown in the image below. For this example we will use this file path to display in our android project.

Create new android project. Or in existing project open Tools -> Firebase and click on Storage to link firebase project with Android project. If you are unfamiliar with this operation then go through this post to check how to connect firebase in android studio.

In build.gradle add dependencies.

We have added firebase storage, authentication and Glide which is image loading and caching library.

Create Glide library module to add support for firebase storage.

FirebaseImageLoader class is a utility class which can be used to load Firebase Storage reference url directly by Glide App.

Once you clean rebuild the project you will be able to use Glide Module to fetch and load image files from the cloud storage.

Now, you are ready to test firebase storage.

Layout file

You can similarly create or delete firebase storage files. Check out the next article to understand how to create new storage file. You will also learn how to delete from firebase database and storage.

Leave a Reply