Android data access design patterns: Content provider vs repository
I wonder what folks use as a common data access pattern on Android? Content providers? Repositories? DAOs?
开发者_StackOverflowThanks a lot!
I utilize Content Providers for all data access to SQLite resources, but build DAOs on top of them to handle all domain object conversions.
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.
精彩评论