I’m starting to learn Android and i would like know the best practice to organize my app.
I’m used to decompose my project in 3parts; Models, Views and Controllers… so in a first case I want to create my package sources like this:
- project.models.* // My all models
- project.ui.* // My all activities
My app needs to communicate with a webservices so:
- project.models.* // My all models
- project.ui.* // My all activities extends ListActivity etc...
- project.io.* // Interfaces between models and webservices.
But I have read a lot of examples and it does not seem to be the right method… I don’t know if it is a good way to try to create a MVC with Android.
How can I start my app in the best way?
In terms of the “best way to organize an app which communicates with webservices” there’s a session from GoggleIO 2010 that I found very useful:
http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html
It’s a high level description of how the Twitter application for Android decomposes responsibility for storing data and communicating with the server. With the pointers from the session I was able to dig up some great info about IntentServices, using ResultReceivers to get notifications back to the UI thread, and using ContentProvider data updates to drive refreshes.
Once you’ve got those parts stitched together to provide the base it’s much easier to assemble a clean MVC on top of it.