Skip to content Skip to sidebar Skip to footer

Is It Possible To Use Contentprovider And Direct Data Access To Database In Android? (multiple Application Case)

I have a similar question as here: Is it possible to use ContentProvider and direct data access to Database in Android? but in my case I want the widget application to be a separat

Solution 1:

I am also trying to use a ContentProvider and a singleton db object. This appears to be a valid approach.

Quoting from: http://groups.google.com/group/android-developers/browse_thread/thread/20d8cbf7bf88f6d9

"Only open the database once. If you are not using a content provider, implement a singleton that takes care of opening the database once for all code in your app.

"And let me be clear -- there is NOTHING wrong with the content provider never closing the database. Nothing. That is NO reason to avoid using a content provider. In fact it is a very good design approach, and if you aren't using a content provider but directly accessing, I would recommend using the exact same approach for the singleton implementation.

"If you want to have a content provider AND also elsewhere do direct access to the database, then implement your content provider on top of the singleton that owns the database.

-- Dianne Hackborn Android framework engineer hack...@android.com

Post a Comment for "Is It Possible To Use Contentprovider And Direct Data Access To Database In Android? (multiple Application Case)"