Press "Enter" to skip to content

Getting Started With Firebase in Android

Greetings People!

Today I am going write about Firebase, which will be targeting mostly the people who don’t know what Firebase is.

What is Firebase?
Before Google owned Firebase. It was real-time database. Now it has many other features like Cloud Messaging, Storage and etc. Read more

Lets start with making a simple application. Open https://console.firebase.google.com/. Login with your google account. Click Create New Project add name and location to it then click Create Project.

create

You’ll be redirected to your project’s dashboard. Then click on Add Firebase to your Android app
add

Add your package name. I have already created a project so I added its name. Then click Add App.

project

After clicking that you’ll get a google-services.json file.

json

Open your project in Android Studio and in the Explorer paste your google-services.json file under app folder.

save

In your Project build.gradle.

proj

And in your Module build.gradle.

module
Then click Sync Now and let it complete.

Click on your Database then click Rules. Make Read and Write both to true.

rules

After that open your activty_main.xml and add a Edit text and a Button, and reference in a the MainActivity.

Create Firebase database object by using the following code:

Now its time to set values to Firebase. In your button listener.

In order to listen to changes to Firebase.

With this being done. You’re all set up and now ready to set data to Firebase.
Run your project and test by sending data.

Testing on Simulator.

You can find this project on Github.
If you have any questions leave a comment. I’ll get back to you as soon as I can. 🙂

See ya!

Author: Aaqib Hussain

Aaqib is an enthusiastic programmer with the love of Swift and anything that looks like Swift i.e Kotlin. He loves writing code in Swift, and exploring new technology and platforms. He likes to listen to old music. When he is not writing code, he’s probably spend his time watching movies, tv-shows or anime, or either doing some research for writing the next article. He started Kode Snippets in 2015.

23 Comments

  1. NA
    NA May 29, 2016

    Too difficult for beginner please make it simple.

    • Aaqib Hussain
      Aaqib Hussain May 29, 2016

      Can you point me out from where?

  2. Homepage
    Homepage November 25, 2016

    … [Trackback]

    […] Read More here: kodesnippets.com/index.php/2016/05/29/getting-started-with-firebase-in-android/ […]

  3. Blackjack Online
    Blackjack Online March 26, 2018

    You actually make it seem really easy together with your presentation however I to find this topic to be actually something that I believe I might never understand.
    It sort of feels too complex and very vast for me. I am having a look ahead on your
    next publish, I’ll attempt to get the grasp of it!

  4. agen joker123
    agen joker123 March 27, 2018

    First off I want to say terrific blog! I had a quick question which I’d like to ask if you do
    not mind. I was interested to know how you center yourself and clear your thoughts prior to writing.
    I’ve had a difficult time clearing my thoughts in getting my thoughts
    out. I do enjoy writing however it just seems like the first 10 to
    15 minutes are generally lost just trying to figure out how to
    begin. Any suggestions or tips? Thanks!

    • Aaqib Hussain
      Aaqib Hussain March 28, 2018

      Hi,
      Really appreciate your kind words.
      When I started writing blogs, I had a purpose which was to not let another developer go through the same pain of implementing something as I did. So this what helps and motivates me to write. Before writing I start to research on the thing I am going to write on, and create a sample project. After I’m done with the sample app, more than half of my work is done then all I have to do is come up with some words to explain what I have done. Hope this helps.
      Cheers!

  5. xsugar18
    xsugar18 March 29, 2018

    I don’t even know how I ended up here, but I thought this post was great.
    I do not know who you are but certainly you are going to a famous blogger if you
    aren’t already 😉 Cheers!

    • Aaqib Hussain
      Aaqib Hussain March 29, 2018

      Thanks for the kind words. *fingers crossed*

  6. 2018 calendar printable
    2018 calendar printable April 2, 2018

    Hello my family member! I want to say that this article is amazing, great written and come
    with almost all significant infos. I’d like to see more posts like
    this .

  7. Your style is sο unique inn comparison tо otһeг folks I have read stuff from.

    Ι aρpreciate yоu for posting ԝhen you’ve got the opportunity,
    Guess Ӏ’ll ϳust book mark this blog.

  8. I have to thank you for the efforts you have put in penning
    this site. I am hoping to see the same high-grade content by you in the
    future as well. In truth, your creative writing abilities has encouraged
    me to get my own site now 😉

  9. details
    details July 27, 2018

    I’ve been surfing online more than three hours today,
    yet I never found any interesting article like yours. It’s pretty worth
    enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.

  10. infomapp.com
    infomapp.com July 28, 2018

    My brother suggested I might like this web site.
    He was totally right. This post truly made my day.
    You can not imagine just how much time I had spent for this
    information! Thanks!

  11. http://totokini.org
    http://totokini.org July 31, 2018

    I’m amazed, I have to admit. Rarely do I come across a blog that’s both equally
    educative and engaging, and without a doubt, you have
    hit the nail on the head. The issue is something that too few men and women are speaking intelligently about.
    I’m very happy I stumbled across this during my hunt for something concerning
    this.

  12. Hi I am so happy I found your website, I really found you by error,
    while I was looking on Digg for something else, Regardless I am here now
    and would just like to say cheers for a remarkable
    post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to look over it all at the minute but I have saved it and also included your
    RSS feeds, so when I have time I will be back to read more, Please do keep up the awesome job.

  13. indotogel
    indotogel September 6, 2018

    Hello, I enjoy reading through your post. I like to write a little comment to support you.

  14. Shanon
    Shanon September 9, 2018

    Great blog you have here.. It’s difficult to find quality
    writing like yours nowadays. I seriously appreciate people like you!

    Take care!!

  15. minecraft
    minecraft September 16, 2018

    Very good post. I’m facing a few of these issues as
    well..

  16. Agen Togel
    Agen Togel September 21, 2018

    Just wish to say your article is as astounding. The clarity in your post is simply excellent and i can assume you are an expert on this
    subject. Well with your permission allow me to grab your RSS feed to keep
    updated with forthcoming post. Thanks a million and please carry on the gratifying work.

  17. Get Free Followers
    Get Free Followers October 15, 2018

    fantastic publish, very informative. I wonder why the opposite experts of
    this sector don’t notice this. You should continue your writing.
    I’m confident, you’ve a great readers’ base already!

Leave a Reply

Your email address will not be published. Required fields are marked *