Sign in Go Pro

Android Model-View-ViewModel Pattern

Adding a Repository

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



In this lesson you'll learn about an important design pattern, the Repository Pattern, to abstract the source of data in your MVVM application. We'll be adding a Repository to the Tip Calculator app to store and retrieve tips calculated by our users at various restaurants. We'll also look at how to test your Repository and how to test LiveData results.

Key concepts in this lesson that you will learn:

  • What the Repository pattern is and how to implement it within your app.
  • A TDD approach to defining your Repository API.
  • What LiveData is and it works in the scope of an Activity
  • How to test LiveData in a JVM / JUnit Test with the InstantTaskExecutorRule
  • What a Junit Test Rule is and how it works


There are no comments on this lesson, start the conversation below ...


Lessons in Android Model-View-ViewModel Pattern