Share Database Between Tabs

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Share Database Between Tabs

Postby glassfish » Thu Apr 09, 2009 7:46 am

Hi,
I have a class that has different tabs, each that I want to access the same database. Each tab executes as a new intent, i.e. new Intent(MYCLASS.class). My question is where do I instantiate the database, and how can I get a cursor to it in the different tabs?

Thanks!
glassfish
Freshman
Freshman
 
Posts: 9
Joined: Sun Jan 18, 2009 10:23 pm

Top

Postby WarrenFaith » Thu Apr 09, 2009 7:50 am

hm... i am using a singleton to handle my database connection... what about this pattern?
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

What Pattern?

Postby glassfish » Thu Apr 09, 2009 7:52 am

What Pattern?
glassfish
Freshman
Freshman
 
Posts: 9
Joined: Sun Jan 18, 2009 10:23 pm

Postby WarrenFaith » Thu Apr 09, 2009 2:17 pm

the singleton pattern?
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby glassfish » Thu Apr 09, 2009 6:11 pm

Oh woops I was confused by the wording. So create a static reference to the class in the parent class of the tabs. I thought about doing this, but thought it may run into problems because I would be changing the database between different tabs. I guess I could synchronize it....
glassfish
Freshman
Freshman
 
Posts: 9
Joined: Sun Jan 18, 2009 10:23 pm

Postby WarrenFaith » Thu Apr 09, 2009 8:03 pm

I have a singleton for every table of my database. Each class has a static class variable which represent itself (this). Implementation like http://en.wikipedia.org/wiki/Singleton_pattern
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests