Nowadays every other android developer is using firebase in some form be it their interface for notifications in your app, their realtime database or their authentication methods. these are just a few example of the much bigger list of the services that firebase provides.
We in this blog are particularly interested in using the database feature that firebase provides and is known as the firebase realtime database. Using this feature is really easy if you know how exactly to do it , else you will find it really difficult to handle .
Steps to follow to get you started :
1) Register your project on the firebase console.
2) Download the google json provided.
3) Upgrade your build.gradle (app module) with the following dependencies.
P.S : A brief introduction to these dependencies :
‘com.google.firebase’ is the default package name that allows you to import the firebase dependencies.
firebase-database : allows you to read the unique link provided to your database in the google service json you just downloaded.
firebase-core: allows you to get the core functionalities you will be using in your project to access the database.
After you have downloaded the json file all you need to do is calll a reference to your database and firebase has made that really simple. Just one line :
private DatabaseReference myDatabase = FirebaseDatabase.getInstance().getReference();
Congratulations, you have got access to your database and now you can use it as per your need.
Now in order to write to your data base you just need to push it , but you need to keep in mind that this database is a noSQL database and recieves the structure in JSON format. so you need to structure your database very nicely in order to achieve what exactly you want to do.
We will look in other coming blogs on how exactly to read and write data into your database.
Keep coding and keep sharing. : )