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.

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.

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.

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.

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.

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

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

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.


hl_divider.png

Thank You

hl_footer_banner.png



0
0
0.000
2 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

Congratulations @faisalamin! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 8000 upvotes.
Your next target is to reach 9000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

0
0
0.000