How to read data from Firebase Realtime Database and display it using Jetpack Compose

Daniel Atitienei
3 min readAug 5, 2022

We’ll be doing this in 2 ways:

Without Hilt

  1. Setup
  2. Creating the ViewModel and gathering the data
  3. Get data once
  4. Listen to data in realtime

With Hilt

  1. Setup
  2. Creating the repository
  3. Implementing the repository
  4. Creating the AppModule
  5. Collecting the data from the repository in the ViewModel
  6. Display the data

Database schema

Get database reference

To get a reference to a database other than us-central1 the default database, you must pass the database URL todatabase()the . For a us-central1 default database, you can call or database without arguments.

You can find your Realtime Database URL in the Realtime Database section of the Firebase console. Depending on the location of the database, the database URL…

--

--