5

I wonder what folks use as a common data access pattern on Android? Content providers? Repositories? DAOs?

Thanks a lot!

TheMadMax
  • 83
  • 5
  • You are right, version control systems normally maintain repositories of source code. However, I was thinking more about repository in terms of domain driven design, this is a brief write up on the pattern: http://www.codeinsanity.com/2008/08/repository-pattern.html – TheMadMax Mar 18 '11 at 11:16

2 Answers2

2

I utilize Content Providers for all data access to SQLite resources, but build DAOs on top of them to handle all domain object conversions.

Brian
  • 1,337
  • 9
  • 25
  • Do your DAO's use Android Cursors still or do you map them to Lists of Strongly typed objects? I'm having trouble deciding whether to return an ArrayList and write a custom ListAdapter for my ListActivities, or if I should just stick with cursors. Cursors seem more efficient. – Manual5355 Jun 23 '12 at 14:47
0

I always create Repository interface and use it in my domain model. Then I have concrete implementation of Repository with raw SQLite, OrmLite, Real etc. I this case it is easy to test your domain model with Unit tests because your read database or android specific components are encapsulated.