I'd like to further clarify one important benefit of ContentProvider lifecycle management for an application with multiple Activities that need to share data.
Putting a database into a Service means that, to use the database, an Activity needs to bind to the Service. Binding is asynchronous, so there is going to be a delay between the time an Activity appears on the screen, and when it can start populating itself with data from the Service's database. Now, I don't know how long of a delay this turns out to be, perhaps not long at all, but there certainly is one. With a ContentProvider, an Activity can start making data queries right inside onStart or onResume. So the delay inherent in the Service pattern is not there, and UI should feel more responsive. -- Kostya Vasilyev -- http://kmansoft.wordpress.com 10.08.2010 1:12 пользователь "Indicator Veritatis" <[email protected]> написал: Kostya hit the nail on the head: the biggest benefit provided by ContentProvider and ContentResolver is probably just that, that it provides lifecycle management on top of database queries. There are also other benefits, such as insulating from the particulars of database, but since we are tied to SQLite3 anyway, I don't see this as nearly as big. Plus, it is a nuisance that the interface 'leaks' a cursor -- forcing you to make it look like a database even in the rare case where there is no database behind the ContentProvider:( But that lifecycle management is a major benefit, since you really would not want to handle releasing and re-acquiring database connections etc. all on your own without that support. ContentProvider also provides consistent means for sharing data between applications, not just between application components of a single activity. On Aug 9, 2:36 am, Sohan badaya <[email protected]> wrote: > Hi All, > > I have a doubt about ... -- 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

