‫Welcome back.
‫Let's start learning about real time databases in Firebase.
‫The Firebase Realtime Database is a cloud hosted database.
‫Data is stored as Json and synchronized in real time to every connected client.
‫Let's move to Android Studio and start dealing with real time databases.
‫Read, write, save data and much more.
‫To start using Firebase databases, real time databases, we need to add it's dependency.
‫So let's go to Firebase Demo app on the console dot Firebase.google.com see all build features.
‫And here I need to enable real time database.
‫Then I need to click on this create database button.
‫Keep the real time database location as default.
‫And I'll start in test mode.
‫This mode is good for getting started with mobile and web client libraries, but allows anyone to read
‫and overwrite your data.
‫Click enable and this is our real time database.
‫You can see we have data rules, backup, usage and extension.
‫For now I'll concentrate on this data section and you can see our link.
‫Our reference URL is this dot firebase I o.com.
‫I'll click on this go to docs to get the dependencies of the Firebase Real Time database.
‫Click on Real Time Database and click on Android Setup.
‫And here I need to get the latest dependency.
‫Again guys.
‫If you use Firebase Bom you don't need to specify the version of your Firebase services.
‫I'll use Java Android and I'll copy this.
‫Go to Kotlin and add the dependency for this real time database and paste it here.
‫Sync now.
‫And you're ready to use the real time database again guys let's move to the rules.
‫And the real time database provides a declarative rules language that allows you to define how your
‫data should be structured, how it should be indexed, and when your data can be read from or written
‫to.
‫Here you can see read.
‫We are enable it and write.
‫You can see that it is for one month from my current date, so it will enable you to read and write
‫from the database.
‫Let's go back to the data section.
‫And this is our reference.
‫And our hierarchy database hierarchy will be displayed here.
‫Now let's move to the main activity here.
‫This is our Empty views activity.
‫In this video we'll learn how to write data and how to insert data into our database.
‫I'll start by creating database instance by using Firebase Database.
‫And you can see I imported this class from the Google Firebase database package.
‫Firebase database database equal to Firebase database dot get instance.
‫Firebase dot get instance method is a method provided by Firebase Realtime Database SDK for Android
‫that allows you to obtain an instance of the Firebase real time database.
‫You typically use this method to initialize and access the database in your Android application.
‫Once you've obtained an instance of the database, you can use it to get references to specific locations
‫or nodes within your database.
‫These references allow you to read and write data at those locations.
‫I start using database reference, my reference equal to database dot get reference method, and here
‫I need to specify the node and this node you want to access within your database.
‫For example path is messages node will be named as messages with a reference to a specific node.
‫You can perform various database operations like reading data with add listeners for single value event
‫method, writing data with set value method and others.
‫In this video, we'll learn about set value method.
‫So I start with my reference dot set value method.
‫And here I need to set the value pass an argument of type string to this set value method.
‫I'll use hello from our course.
‫Let's run our application and make sure that you add the internet permission in the Android manifest.
‫In order to access the internet by using user's permission.
‫Internet.
‫Let's run again.
‫This is our application.
‫Hello world.
‫Nothing to display and you can see messages node is created and the value hello from our course is added.
‫So congratulations guys.
‫We created our real time database.
‫We get the reference and we insert data in this database.