How to add firebase Real Time database in Android App

Steps to add firebase Real Time database in android app
  
A) Add firebase to your app

    1. Create firebase project from firebase console. If you have Google project associated to your android app then just click on import Google project option otherwise proceed with new project option in firebase console.
    2. If you are clicking on import google project option then everything will be configured  by firebase, you just need to follow steps and lastly download the config file.
    3. If you click on new project option, then new project will be created. Your application is  recognised by package name entered in project name field in create project wizard.
    4. At the end download google-services.json file and paste this file in your android project's app folder.
       
B) Add firebase sdk

    1. In your root level build.gradle file add classpath in dependencies section :
        dependencies {
            classpath 'com.google.gms:google-services:3.0.0'
        }

    2. Then add apply plugin:'com.google.gms.google-services' at the bottom of the file in your app level build.gradle file.
    3. Add compile 'com.google.firebase:firebase-core:9.2.0' in your app  level dependencies.

C) Adding firebase realtime database to android project

    1. Add compile 'com.google.firebase:firebase-database:9.2.0' to your projects app level gradle dependency
    2. Configure firebase database rule. The database configuration is important in firebase, by default data in firebase is authenticated and can not be read write by anyone . But you can make it public by clicking on public tab in database tab in project of firebase console.
    3. You can now write your database to firebase and you can easily retrieve it by calling valueEventListener() on database reference object

Boston Byte Grabs a Spot in Clutch’s List of Top Software Developers in Massachusetts

Boston Byte is a collective of highly-skilled and highly-professional developers dedicated to solving your technological ...