Cloud Firestore with MVVM in Android Q Kotlin: Overview and Example

preview_player
Показать описание
A quick overview, followed by a simple hands-on demonstration where we:
1) create a Firebase project,
4) create a save method in our VIewModel, which will be invoked from our fragment,
5) send a populated object from the Fragment to the ViewModel to be saved,
6) add FirebaseFirestore to our ViewModel,
7) build FirebaseFirestoreSettings,
8) access a CloudFirestore collection, and add a new document to it,
9) add onSuccessListener and onFailureListener,
10) demonstrate our work in the debugger,
11) see the difference between setting our own document ID versus having one generated for us, and
12) see how we can read a document ID that was generated automatically by Firebase, and store that generated ID in our DTO.

Рекомендации по теме
Комментарии
Автор

Like always, brilliantly explained! Thanks Mr. Jones. I was getting nervous about using Firestore but it looks so easy now.

norulesprateek
Автор

Very well explained sir, Awesome coding style.

fahadtahir
Автор

You should use Android KTX for more concise and idiomatic Kotlin code. For example getting a reference to the viewmodel becomes val viewModel by viewModels<MyViewModel>()

hugosalazar
Автор

Can I use Realtime DB for this as well?

ezscootrr