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

Reply via email to