jetpack part document
转载原因
文章充分介绍了使用jetpack ViewModel 、LivaData、Room的使用案例
文档地址:https://developer.android.com/codelabs/android-room-with-a-view-kotlin
文档源码地址:https://github.com/googlecodelabs/android-room-with-a-view
content
Entity: Annotated class that describes a database table when working with Room.
SQLite database: On device storage. The Room persistence library creates and maintains this database for you.
DAO: Data access object. A mapping of SQL queries to functions. When you use a DAO, you call the methods, and Room takes care of the rest.
Room database: Simplifies database work and serves as an access point to the underlying SQLite database (hides SQLiteOpenHelper). The Room database uses the DAO to issue queries to the SQLite database.
Repository: A class that you create that is primarily used to manage multiple data sources.
ViewModel: Acts as a communication center between the Repository (data) and the UI. The UI no longer needs to worry about the origin of the data. ViewModel instances survive Activity/Fragment recreation.
LiveData: A data holder class that can be observed. Always holds/caches the latest version of data, and notifies its observers when data has changed. LiveData is lifecycle aware. UI components just observe relevant data and don’t stop or resume observation. LiveData automatically manages all of this since it’s aware of the relevant lifecycle status changes while observing.