CRUD Operations With FCM Database Using Kotlin - Part One - Connecting Firebase

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

  • A Gmail account
  • Android Studio 3.0.0 or later
  • Internet connectivity

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

  • Now click on “Launch in browser” hyperlink from from Firebase Assistant. Then “goto console”.
  • Make sure you have only one gmail login from which you have connected to firebase.
  • Now select your project which was just created, and click on Database -> create database.
  • Select start in test mode and click on Enable button.

    CRUD Operations With FCM Database Using Kotlin

  • Now go to top and select “Realtime database” -> Rules and modify read and write permission as true. Then click on publish button.

    CRUD Operations With FCM Database Using Kotlin

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."


Similar Articles