Also See

In our application development life cycle, we all have to deal with things like web service management, parsing of data and using parsed data in our mobile application. We also set up about push notifications about data changes in order to keep every user updated about the system. And we also have taken tension of third-party integration like Facebook or Google in order to authenticate data. To keep all these things in one place, Firebase technology has arrived!

How will Firebase ease the development approach?

Firebase is a BAAS (Backend As A Service) technology which helps users to keep their data on the server. Users can store and access their data for their mobile application and have instant updates if any changes occur in the database.

Some important features:

Data is stored in key-value pairs. Means, it will be structureless.

Users do not have to worry about data change notifications. If any data change occurs, it will be reflected directly to the client side.

Firebase provides authentication system via Google or Facebook so developers can control data access.

3. Add permissions

4. Setup Firebase context

The Firebase library must be initialized once with an Android context. This must happen before any Firebase app reference is created or used otherwise your application will crash.To do this you can set the android context in your app’s application class.

5. Do simple read and write operations

That’s it! You have set up Firebase on your application and you can now use it for database management! You have to create an instance of firebase to access Firebase data.

Example:

Firebase mFirebaseRef = new Firebase(FIREBASE_URL).child("chat");

Here FIREBASE_URL is the string of your database and child is a particular node name where you have to save data.

Write data

You can write data by accessing instance you created.

myFirebaseRef.child("chat").setValue("Hii how are you?");

Read data

To read data from the database, We have to add listeners in following way.

Now whenever new data is inserted, updated or removed on chat node of Firebase, it will be listened by the listener we have created. We can access that value according to our needs.

So this was the very basic setup of Firebase, you can access security features, third-party authentication and much more!

You can visit Firebase website for more details.

Further reading:

For more information and latest updates, you can visit official firebase website. You will find the official tutorials for android development here so you do not need to refer other websites for tutorial.