Implementing Repository class with Room.

Previous post suggested an idea for architecting Android app, using the new Android Architecture components.

We talked about the architecture layers and separation between them:

I presented a jelly bean recipes app that will be used for demonstration. If you haven’t yet, take a couple of minutes to read it, so that everything can be clearer.

Last time we mainly discussed the Presentation layer. And now..

Time to save the bean!

After filling in the flavor name and color, we’ll click on the “SAVE” button, to save the jelly bean.

How should we do that?

The button belongs to the Presentation Layer. The jelly bean once saved, becomes data, which belongs, obviously, to the Data Layer. Since the layers are separated, the button doesn’t know where the jelly bean data will be saved, how will it be represented when stored, or even whether or not will it be saved.