Muhammad Faisal Amin avatar

Save Data in Firestore | Android App Development | Lecture#54 | Hive Learners

faisalamin

Published: 24 Aug 2022 › Updated: 24 Aug 2022Save Data in Firestore | Android App Development | Lecture#54 | Hive Learners

Save Data in Firestore | Android App Development | Lecture#54 | Hive Learners

𝓖𝓻𝓮𝓮𝓽𝓲𝓷𝓰𝓼

Dear Hive Learners in Lecture 53 we learn how to configure Firebase Firestore to our project. We also learn what the advantages of Firestore.Today we will practically store data in the Firestore and fix some bugs in the current code. Let's get started.

alt

GitHub Link

Use this GitHub project to clone into your directory. The following lecture will update it so you will never miss the latest code. Happy Coding!

What Should I Learn

  • How to store data to Firestore

Assignment

  • Store data in Firestore

Procedure

First of all, we need to add the data in a hashMap that we need to store. Declare and initialize Firestore that we have already done in lecture 53.

alt

We will use the name sendings as the parent path. In Firestore it is called the collection, and the child of a collection is called the document. We will use doc_id to set the document ID and also store this PushKey.

alt

Copy the task complete listener code that is in the sendings_ref. We are going to remove this code but the onCompleteListener can be reusable. Also, move the progress dialog code on top of this Firestore listener.

alt

Run the loginand ogin to the app. Today I run the App on my real Mobile Device and I get an Error. I look into the code and finally found that there were two theme files one for the daily theme and one for the night. We change the parent theme In the theme.xml but do not change it in the theme.xml night file. On my mobile device dark mode is on and the app is crashing so we need to set the parent theme to MaterialDesign in the night theme also.

Copy the theme.xml code and paste it into the night theme.

alt

We also need to set the Database in the Firebase Console. Open the Firestore window.

alt

Click on create a database and wait until it is complete.

alt

alt

alt

Run the app and store the data. Data is saved successfully in the Firestore database. In the next lecture, we retrieve this data in our app.

alt

alt

hl_divider.png

Thank You

hl_footer_banner.png

Leave Save Data in Firestore | Android App Development | Lecture#54 | Hive Learners to:

Written by

Android | Python | Software Engineer

Read more #hive-153850 posts


Best Posts From Muhammad Faisal Amin

We have not curated any of faisalamin's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Muhammad Faisal Amin