freeCodeCamp/guide/english/android-development/firebase/realtime-database/setup/index.md

2.5 KiB

title
Setting up Firebase Realtime Database

Prerequisites

  1. The latest version of Android Studio
  2. Have connected with Firebase manually or via Firebase Assistant(See Connecting to Firebase).
    It is recommended that you do this so as to not be confused by partial instructions related to this in the docs mentioned below.

Setting it up with Android Studio


After adding Firebase to your project, you will need to add extra dependencies and do some other things in order to setup the Realtime Database. There are two documentations about this:
  1. Firebase quickstart docs
  2. Google docs

There are some discrepancies between the two. To make up for them, you can follow the Firebase docs, but instead of just using the gradle dependencies listed there, use the following list. That way, you will not miss any steps from either documentation.


Add Gradle Dependencies1
In your app-level build.gradle file, add the following

dependencies {
    implementation 'com.firebase:firebase-client-android:2.5.2+'
    implementation 'com.google.firebase:firebase-database:15.0.0'
}

Installation of Firebase Android SDK, permissions and setup code

Detailed instructions for these can be found here.

Resources

To learn about how to read from and write to the database in your Android application, refer to the two docs listed in References.
You can also find out how to use Firebase products in the Google documentation, but again it is probably a good idea to look at the Firebase docs as well, or anything that might be helpful.

References

Footnote

The first line comes from the Firebase docs on setting up realtime db in Android Studio.
In the docs, 'compile' is used but that is deprecated and replaced by 'implementation'.
The second line comes from the Google docs on setting up realtime db in Android Studio.
If it is actually redundant to add both, please correct this article.