There are two considerations: database design and application design. Database design is much too big of a topic to summarize in a single thread! But in short, one wants to normalize the data and do joins to combine data from different tables.
Application design in Android suggests that a ContentProvider isn't necessary for private data. Basically, if you don't want to let other applications look at your data (or modify it, or delete it) by themselves, then you don't really need a ContentProvider. Of course, you can have one if you want. You lose a bit of security, since the data becomes "public", although you can keep pretty much private by using an obscure URI. Also, it's best to have one database per ContentProvider. If you find yourself trying to associate more than one database with the same ContentProvider, your design may be suspect. Remember that a single database can contain address data, book data, and people data, if the domain is library management. On the other hand, you may choose to use the built-in Contacts provider for people/address and your own ContentProvider for books. In short, there's no one answer, except that you aren't limited to one table per ContentProvider, one database per ContentProvider, or one ContentProvider per Android application. A ContentProvider has some overhead, but I'd opt for one per database rather than worry about the overhead. On Aug 24, 9:17 am, Kostya Vasilyev <[email protected]> wrote: > A ContentProvider is queried (and updated) using a URI, which > specifies the kind of data to work with. This might look like this: > > content://<provider>/counties > content://<provider>/counties/<country_id> > > content//<provider>/counties/<country_id>/cities > content//<provider>/counties/<country_id>/cities/<city_id> > > Or even like this, in addition to the above: > > content://<provider>/books > content://<provider>/books/<book_id> > > A helper class, UriMatcher, can be used in ContentProvider > implementation to quickly and easily determine what kind of data a > request URI refers to - whether it's counties, or cities, or a country > by its id (in the examples above). > > One the kind of data that the URI refers to is known, it's quite logical > to store each kind of data in its own table (e.g. country / city). > > I also think it makes sense to implement separate ContentProviders for > unrelated sets of data. > > In the example above, if you're not linking books to cities, you might have: > > content://name.Arpit.GeographyData/counties > content://name.Arpit.GeographyData/counties/1 > content://name.Arpit.GeographyData/counties/1/cities > > ...etc... and: > > content://name.Arpit.Library/books > content://name.Arpit.Library/books/1 > content://name.Arpit.Library/books/2 > > -- Kostya > > 24.08.2010 20:01, Arpit пишет: > > > > > > > Hi All, > > > All the example codes, tutorials or video I see, there is always one > > ContentProvider per SQL Table with the SQLiteOpenHelper extension > > defined as a private static class... > > > Is it some sort of standard design...to have one ContentProvider per > > SQL Table? Or I can define one generic ContentProvider and use its > > instance for ever update? > > > Is there some issue with that? > > > Could anyone please help as my application has like 5-6 tables. > > > Regards, > > Arpit > > -- > Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

