Steps to create a MVVM pattern using DB of ShoppingItem list:
- Create class Entity ShoppingItem (Has every attirbutes)
- Create interface Dao for ShoppingItem(Has the functions like upsert, delete, getall, get…)
- Create abstract class ShoppingDatabase (Has the database creating code)
- Create class ShoppingRepository(ShoppingDatabase) (Implements the Dao interface)
- Create class ShoppingViewModel(ShoppingRepository) (Uses the repository methods)
- Create class ShoppingViewModelFactory(ShoppingRepository) (Uses the ShoppingViewModel)
- Create ShoppingApplication: Application(), KodeinAware() (Used for creating DB, Repository and finally ViewModel instance)
- Use ViewModel created in ShoppingApplication in ShoppingActivity