Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

firebase
database
java

What is a Firebase database in android development?

Dian Us Suqlain

What is Firebase?

Developed by Google, Firebase is a real-time database that stores and updates data on the cloud. We can use Firebase on various platforms including Android, iOS, and the web.

Firebase supports a JSON format for displaying data to users. A developer can perform basic CRUD (Create, Read, Update and Delete) operations using the Firebase database platform.

To use Firebase as our database, we have to register and create an account at the official Firebase website here.

Uses of Firebase

Although Firebase works as a database, it also has various other usages, as shown in the illustration below.

Uses of firebase

Advantages of Firebase

Firebase comes with many advantages, as it reduces workload and saves costs for a developer. We mainly use this database because of the following benefits:

  1. Real-time updating of data
  2. Offline availability
  3. Centralized database for all connected devices
  4. Easy understanding
  5. Cloud messaging

How to integrate the Firebase database in an application

We use Firebase as an APIApplication Programming Interface: a bunch of code that acts as an external interface between two computers in a mobile or web application.

We must properly integrate this database into our project by syncing the appropriate libraries and dependencies, available on Google’s official documentation site for Firebase, mentioned here.

Example

Let’s get a better understanding of how to integrate Firebase by importing it into Android Studio.

Step 1. Go to Android Studio. If we don’t already have it, we must download and install it first. Create a new project.

Step 2. Once our empty project is fully loaded and Gradle files are synced properly, go to tools -> Firebase. Once a new window opens, locate and select Save and retrieve under the Realtime Database section.

Firebase assistant in android studio

Step 3. Connect our Firebase project and move to set our dependencies.

We can now apply CRUD operations using Firebase.

Save and retrieve data in firebase android studio

What does the data in Firebase look like?

Firebase stores the real-time data in a JSON format. The format is described below.

Suppose we have an android application that asks the user for some input. Firebase stores that input in real-time and presents it in JSON format.

We can view this type of data on web browsers by locating the specific URL of the Firebase application.

Note: The Firebase application URL is visible on the Firebase webpage where we register the account.

RELATED TAGS

firebase
database
java

CONTRIBUTOR

Dian Us Suqlain
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring