Updated 28 October 2017
Hello everyone,
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.
1 2 |
compile 'com.google.firebase:firebase-database:9.6.1' compile 'com.google.firebase:firebase-core:9.6.1' |
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 :
1 |
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.
Thanks!
Keep coding and keep sharing. : )
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
1 comments