Android Application Architecture - Separating Code and Database Layers

I am writing an Android application that does the following:

  • Get data from the server.
  • Save the data to the database.
  • Refresh views with data from the database.

In my previous applications, I used to write service calls using Ion and then make a DB call using ORMLite and update the views. All the code was in the corresponding Activity or fragment.

The result is a lot of repetitive and redundant code.

You can recommend how to separate these layers.

thank

PS: I have ideas on how to do this, but it requires going around the context and increasing the complexity of the callbacks.

+3


source to share


1 answer


The best practice for your requirements is to follow the design pattern and I recommend the MVP design pattern. Find the link below to learn how to implement the MVP design pattern



http://antonioleiva.com/mvp-android/

+1


source







All Articles