Introduction
The APK keeps details of the user as in which term he/she is, which courses he/she opted for, what are the assessments the user had to go through and some useful details like start date of term, end date of term, instructor details, etc. Users can add these details in the APK.
Concepts Used
As the APK is more about how data will be stored and what should be the model of data, So this article will deal with most of the technical concepts of Data Storage.
Activities
Major activities which user deals with are-:
Main Activity
In this activity the user will have his terms, in which term the user is and he can add terms to the activity.
Course Activity
As the user taps on any of the terms, he proceeds to the course activity, which contains courses the user is having in that term, and the user can add courses as well.
Assessments Activity
As the user taps on any one of the courses he proceeds to the assessments which that course is having and he can also add assessments.
Course Details Activity
This activity contains course details like start date of course, end date of course, status of course, instructor details, etc. We can get to this activity while long tapping any course from the course activity.
Data Models
We used two models “Term” and “Course”, to store our data in Firestore.
Database
For databases we are using Firestore, which is a flexible, scalable NoSQL cloud database to store and sync data for client- and server-side development. Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud. Like Firebase Realtime Database, it keeps your data in sync across client apps through realtime listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity. Cloud Firestore also offers seamless integration with other Firebase and Google Cloud products, including Cloud Functions. When we structure our data in Cloud Firestore, we have a few different options:
Documents
Multiple collections
Subcollections within documents
Nested data in documents
We can nest complex objects like arrays or maps within documents.
Advantages: If you have simple, fixed lists of data that you want to keep within your documents, this is easy to set up and streamlines your data structure.
Limitations: This isn't as scalable as other options, especially if your data expands over time. With larger or growing lists, the document also grows, which can lead to slower document retrieval times.
What's a possible use case? In a chat app, for example, you might store a user's 3 most recently visited chat rooms as a nested list in their profile.
alovelace
name :
first : "Ada"
last : "Lovelace"
born : 1815
rooms :
0 : "Software Chat"
1 : "Famous Figures"
2 : "Famous SWEs"
Subcollections
You can create collections within documents when you have data that might expand over time.
Advantages: As your lists grow, the size of the parent document doesn't change. You also get full query capabilities on subcollections, and you can issue collection group queries across subcollections.
Limitations: You can't easily delete subcollections.
What's a possible use case? In the same chat app, for example, you might create collections of users or messages within chat room documents.
collections_bookmark science
class software name : "software chat"
collections_bookmark users
class alovelace first : "Ada" last : "Lovelace"
class sride first : "Sally" last : "Ride"`
class astrophysics
...
Root-level collections
Create collections at the root level of your database to organize disparate data sets.
Advantages: Root-level collections are good for many-to-many relationships and provide powerful querying within each collection.
Limitations: Getting data that is naturally hierarchical might become increasingly complex as your database grows.
What's a possible use case? In the same chat app, for example, you might create one collection for users and another for rooms and messages.
collections_bookmark users
class alovelace first : "Ada" last : "Lovelace" born : 1815
class sride first : "Sally" last : "Ride" born : 1951
collections_bookmark rooms
class software
collections_bookmark messages
class message1 from : "alovelace" content : "..."
class message2 from : "sride" content : "..."
Cloud Firestore retrieves data in a structure it calls a Snapshot. A DocumentSnapshot contains data for a single document, while a QuerySnapshot returns data for zero or more documents. ... To “listen” for changes on a document or collection, we create a snapshot listener.
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.
@Override
protected void onStart() {
super.onStart();
DatabaseReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(DocumentSnapshot documentSnapshot, FirebaseFirestoreExceptione){}
});
}
If you are looking for Android Assignment Help or Homework Help? Codersarts Androidassignment help expert will provides best quality plagiarism free solution at affordable price. We are available 24 * 7 online to assist you. You may chat with us through website chat or email or can fill contact form.
Comments