I agree with Kostya. I used singleton pattern in my application. Initialize instance of db class in subclass of Application.Now i can use same object through out application.
On Tue, Feb 22, 2011 at 4:16 PM, Kostya Vasilyev <[email protected]> wrote: > 22.02.2011 13:32, ydm пишет: > > I'm curious why the SQLite db requires a Context object, >> > > The database class doesn't - SQLiteOpenHelper (subclass) does, to get the > location of the database file. > > > and what I >> should do to share the same instance of a db object between many >> activities? Should I initialize it in the first activity and use it >> across the application, or may be any activity should reinitialize the >> db with itself as db context? >> > > If you're not going to implement a private content provider (which is one > way), I'd use a simple singleton, keeping a reference to one and only > SQLiteOpenHelper subclass object, initialized with the application context. > > -- Kostya > > -- > Kostya Vasilyev -- 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 > -- 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

