Learn Android MVP Basics.
This article, I Am sharing who want to use Android MVP. So we have created a small sample app that will help you to create your first app using MVP structure.
Why do we need MVP or any structure?
MVP Stand for Model View Presenter. While working with a long-term project, need to be scalable, less complicated. MVP makes it possible by dividing code structure into three different faces (MODEL – PRESENTER – VIEW).
Let’s Start to Understand how MVP work In Android :
The model manages the data components that provide functionality like fetch, store, sort and expose data.
View manage the user interface actions UI.
Presenter works as an intermediator between View and Model. Presenter accepts event from View, analyze the action, get required data from Model and send data back to View for update UI.
Why Use MVP?
This MVP design pattern helps to segregate code into three different parts: business logic (Presenter); UI (View); data interaction (Model). This modulation of code is easy to understand and maintain.
For example: In our application, if we use a content provider to persist our data and later we want to upgrade it with an SQLite database, the MVP design pattern will make this very easy.