Introduction

In this article I am going to illustrate how someone can perform FCM database operations using Android Studio and Kotlin programming language.The prerequisites to understand this article are basic knowledge of Kotlin and familiarity with Android studio.

Requirements

Let us start,

Step 1

Create an Android Studio Project.

Open Android Studio 3.0.0 ->create a new project ->set Project Name & Location ->choose category - phone and Tablet with API 19 -> Select Empty Activity ->Finish.

Step 2

Now you have to connect your project with Firebase as below –

Go to Tools ->click on Firebase

CRUD Operations With FCM Database Using Kotlin

It will open Firebase assistant .

Step 3

Choose Real Time database -> Save and Retrieve data from Firebase Assistant.

CRUD Operations With FCM Database Using Kotlin
Step 4

It will display two options,

  1. Connect to Firebase

    Needs Gmail id and password to log in and allow Android studio to access your Gmail account .Now create a new project “FcmRealTimeDatabaseCRUDkotlin”. Then click on Connect to Firebase button. It will configure your project and sync with ‘google-service.json’ file automatically. Make sure ‘connect to firebase’ is now connected.

    CRUD Operations With FCM Database Using Kotlin

  2. Add a Real Time Database to your project

    Click on “Add RealTimeDatabase to your project” in Assistant panel.

    CRUD Operations With FCM Database Using Kotlin

    CRUD Operations With FCM Database Using Kotlin

    Now make sure “Add RealTime Database to your project” has been converted into “Dependancies Setup correctly.”

    Now you have connected your project with Fcm Real Time Database. If you have any sync error kindly go through your gradle module app file by matching all compile dependencies.

Step 5

Conclusion

Using these steps you will be successfully connected to Firebase Real Time Database from which you can perform CRUD operations. Although I have tried my best to make all these steps clear, you may still have some issues due to interruption of internet connection, multiple Gmail accounts logging in, or conflict dependencies in different versions. So let me know in the comment box if you have any issue.

I will continue this article in the next part, “CRUD operations with FCM Database using Kotlin."