Android Developer

Los Angeles Freelance Developer

Android Developer header image 1

Android Architecture: Part 7, Persistence

November 26th, 2011 · Android, OOP

We’ve made it through all the hard stuff. If you can do MVC in Android, the rest of this series is going to easy. Grab a beer and reward yourself and let’s talk about data persistence.

I’m going to assume you already know about sqlite and otherĀ persistence features in Android. If not, now is a good time to go check that out. I’m going to suggest a concept known as Data Access Objects or DAOs. The idea is super simple: we pass a model to an instance of a DAO and it saves, updates, or deletes for us. So instead of having tons of sql spaghetti string queries all over the place, it’s all done through the DAO. Seems easy, right? Right. Let’s check out some code. [Read more →]

→ 4 CommentsTags:··

Android Architecture: Part 6, Putting it Together

November 25th, 2011 · Android, OOP

So far we’ve discussed Models, Views, and Controllers. And now let’s discuss how we stick them together to make 1 cohesive unit of the MVC paradigm.

The Activity is our entry point for each new view of our application and it’s in the onCreate() method that we will need to instantiate our model and controller. In a typical MVC the view does not create these but, eh, what can you do. Once the model is created, we need to register the activity as a listener. And additionally, if you want to receive messages from the controller, you can register it as well. Let’s take a quick look at what that looks like. [Read more →]

→ No CommentsTags:···

Android Architecture: Part 5, The Controller

November 25th, 2011 · Android, OOP

Of the 3 parts of MVC, the controller is the heavy lifter. The model is nothing more than a glorified name-value object and a good view is “dumb” and just updates when the model changes and does whatever the controller says. (The word “dumb” is common when talking about views and it’s a good thing for our views to be dumb.) The controller does 3 things: 1) updates the model, 2) handles messages from the view, and 3) sends messages to the view. This section will focus on the last two. [Read more →]

→ 6 CommentsTags:···

Android Architecture: Part 4, The View

November 25th, 2011 · Android, OOP

What is a View?
In Android, Activities are going to be our architectural views. Having the Activity serve the role of a view isn’t too intuitive. Because Android creates the Activity for us and manages its lifecycle, it’s difficult to conceptualize the role an Activity should do. Heck, it even comes with tons of hooks like: [Read more →]

→ 9 CommentsTags:····

Android Architecture: Part 3, The Model

November 25th, 2011 · Android, OOP

MVC General Concepts:
To quickly review, MVC is a compound pattern meaningĀ severalĀ patterns comprise this architectural pattern. The Model represents our application’s state. Remember, objects have state (properties) and behaviors (methods). And so applications have state (the model). In essence, models are just big name-value objects that dispatch events when its state changes. Views are the things you see and interact with. They bind to the model by registering themselves as observers. [Read more →]

→ 6 CommentsTags:···