Introduction to Android MVP Pattern


MVP or Model-View-Presenter is a pattern that was derived from MVC. It’s now gaining importance in growing Android development since it has many advantages against the basic pattern.

So what’s MVP? It’s a Android development pattern that allows separate the presentation layer from the logic, so we can make this presentation layer more usable by various fragments that has same behavior.

So what does that mean?

We can make our application more modular with this pattern. In Android we have problem arising from the fact that Android activities are closely coupled to both interface and data access layer. For large application to be easily extensible and maintainable we need to separate application into some layers.

MVP can make our developer life easier. It’s really complex when we started doing this. But in the future, we can add more features easier because it’s modular.

So how to implement it? There’s no standard about how we define this MVP pattern. But the concept is we must separate view, data model interaction and the presenter into different layer.

  1. View

    In Android application, we can implement view using activities, fragments or other views. Unlike normal pattern when we have to implement how to deal with the data inside this view class, MVP pattern only allows this class to call presenter function to deal with data interaction. So this view mostly only does the basic view life cycle.

  2. Model

    Now, most Android application uses data from backend to minimize storage usage in device. This layer mostly be the gateway between the data from backend and the presenter.

  3. Presenter

    Presenter will act as an agent between the model and the view. Basically the presenter just receives data from model and returns it to the formatted view. Not only that, it also controls the interaction in the view.

One thought on “Introduction to Android MVP Pattern

Leave a Reply