0

this is probably an obvious question, but i somehow can't figure it out..

so i'm new to android development, and in the process of building a practice application. in my application i have several models. there's a user, a user can have many shops, and each shop can have many products.

so it's basically User, Shop, Product.

am i supposed to create a content provider for each model/table? or is it one Content Provider, but depending on the Uri that's passed in, it decides which model/tables to create/update/delete/query from?

it almost seems to me that a content provider is like an internal REST api.. if that's the case i imagine i would only have one content provider and i would do all the CRUD operations the way i do it in my REST api.

thanks in advance!

Khon Lieu
  • 4,295
  • 7
  • 37
  • 39
  • Do you really need a Content provider, perhaps having only the tables will suffice? – Alexander Kulyakhtin May 02 '12 at 14:45
  • @Alex i was actually thinking the same thing. i was reading on the [android develoepr](http://developer.android.com/guide/topics/providers/content-providers.html) website that we don't need one if we don't intend to share our app data, which in my case i dont. but i figure it'll be a good learning exercise. – Khon Lieu May 02 '12 at 18:07

1 Answers1

0

after doing quite a bit of research i found that if the domains are related putting them all in one content provider is the way to go.

a good example would be contacts content provider from android. you can look up various data from different tables from a single content provider.

this answer was also very useful.

Community
  • 1
  • 1
Khon Lieu
  • 4,295
  • 7
  • 37
  • 39