‫Hello, my friends, and welcome back.
‫In this video, we will learn about a new product from Firebase called the Storage.
‫So the storage you can select, build and select storage from here.
‫Till now, we've learned about real time database, Firestore database authentication.
‫And in this video we're going to learn about storage.
‫So why we need to use storage since we're going to store journals that contains data, text and of type
‫and object of type journal.
‫We need to store it on Firebase storage so storage store and retrieve user generated files like images,
‫audio and video without server side code.
‫Click on Get Started, Select Start in test mode.
‫And.
‫You can see start in production mode.
‫Allow, read and write.
‫If false and start in test mode.
‫Read and write.
‫Of course.
‫So the default security rules for test mode.
‫Test mode.
‫Allow anyone with your code and your storage bucket reference to view, edit and delete all data in
‫your storage bucket for next 30 days.
‫Click next.
‫And click done.
‫And similar to the previous products that we've learned about, you can see that this is the storage
‫control panel.
‫You can see here the files, the rules and the usage.
‫I will change the rules.
‫I you can you can set it for false if you are allowing only to write or read.
‫You can see you can set the the the rules here in this tab.
‫You can see the usage.
‫You can see how how much you are spending and spending and how much you are using from the storage bandwidth.
‫But we are interesting now in using the files tab here.
‫Let's get the reference to this storage link.
‫You can see Google Services, GS Journal, Kotlin Appspot.com.
‫Now I will get this reference.
‫And use it inside this journals journal list activity.
‫This is what we've learned before and this is what we created before.
‫And now I will start with the late initiate binding for this activity journal list binding.
‫I will create a some objects and some references to our Firebase products like authentication, Firestore
‫and storage reference.
‫So here Firebase references.
‫We will start with Val Firebase Auth Firebase Auth.
‫It's of type Firebase, OAuth and.
‫Or I will make here late initiate var and late initiate var.
‫I will use.
‫User Firebase.
‫User.
‫And I will name it as user.
‫And here.
‫I will use light and shade.
‫Var firestore.
‫Firebase Firestore and its name as Firestore.
‫DB But instead of late initiating this, I will directly create a var.
‫Equal DB.
‫Equal firebase firestore dot get instance.
‫This is for the DB.
‫Now let me create late Inc and late initiate a variable of type storage reference.
‫Since I'm using the storage dependency as the storage product, I need a storage dependency, so I will
‫go to documents.
‫So whenever you get missed, you always refer to go to docs here select storage.
‫Select Android.
‫Get started.
‫Scroll down to get the dependency.
‫And this is the dependency for the storage.
‫Let me go to the gradle here.
‫And here I will paste the storage click sync now.
‫And since I'm using the bomb again and again, I will repeat this note because it's very important.
‫No need to specify the, um, the version of this, these products or firebase products.
‫Back to the journal list.
‫Late initiate var storage reference.
‫It's of type.
‫Storage.
‫Reference.
‫And here I will create this AR for Firebase.
‫Here I will create the list.
‫The journal list so far.
‫Journal list is of type journal.
‫List or list of type journal.
‫List.
‫Or sorry, Jordan.
‫Late in shade, Of course.
‫And here late in shade var recycler adapter so journal recycler adapter or adapter I will name it as
‫adapter journal recycler adapter.
‫I will create a collection reference to the DB and the date on the firebase references here.
‫Var.
‫Collection.
‫Reference.
‫It's of type collection reference equal to.
‫DB dot collection.
‫And what is the name of the collection that I'm going to store?
‫Inside this database.
‫I will name it as journal.
‫Okay.
‫And of course, I need for the widget here late in shade var text view.
‫No posts.
‫Text view.
‫It's of type.
‫Text view.
‫Now let's initialize these things that we have set it here.
‫Open the Oncreate method.
‫Let's start with the binding.
‫So here the binding equal to data binding util dot setcontentview.
‫This AR dot layout dot.
‫Journal list.
‫The second thing I need to initialize is the Firebase authentication.
‫So this is the Firebase authentication.
‫Firebase auth equals firebase.
‫Oth dot get instance and user equal to firebase oth dot get current user or current.
‫User.
‫You can see if I open the sign up activity.
‫This is what we've done here.
‫We created and initialized the oath equal Firebase Oath.
‫What you can't see like this Firebase dot.
‫Oath.
‫Okay.
‫Alt+ enter to import it.
‫And here I need to add non null asserted operator.
‫This is for Firebase authentication.
‫Now I need to initialize the recycler view, so I need to connect it with the adapter.
‫No posts and the widget.
‫Note Posts text view.
‫I need to remove it.
‫Like this to hide it and display it.
‫If if the according to the size of the journal.
‫This.
‫So.