March 23, 2025
+ 12

The Model-View-Presenter pattern

In our app, we follow the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view.

android mvp model

In the Android Studio project, the code is structured by feature. You can select the Android option in the left navigator to view the files by package.

android left navigator

Each package contains 3 different files:

  • Activity: This is where all the view logic resides.

  • Presenter: This is where all the business logic resides to fetch and persist data to a web service or the embedded Couchbase Lite database.

  • Contract: An interface that the Presenter and Activity implement.

Throughout this tutorial, we will walkthrough the code in the various presenters to showcase different features of the Couchbase Lite API:

  • BookmarksPresenter.java

  • HotelsPresenter.java

  • SearchFlightPresenter.java

  • BookingsPresenter.java.