Cain Wong
Cain Wong
Feb 23, 2017 · 1 min read

Hi there. Use of a Cursor (or Database for that matter) is an implementation detail that should be abstracted from a Presenter. Instead put them inside some kind of DataManager-type class that gets injected into the Presenter. This way, the Presenter is only concerned with taking the returned data and setting it in the view. You should be able to swap out the datasource implementation from a Database, to a network API call, to an in-memory store without the Presenter knowing anything about it. I have a recent implementation of this concept in a sample project for a library I wrote recently. I use it with a network API in this case, but it can easily be used for other datasources. Here is DataManager class. Also, if you want to check out the library, here is an article I wrote about it. I’d love to hear your thoughts.

    Cain Wong

    Written by

    Cain Wong

    Code, music, kung fu… but mostly code

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade