I have a central database in my application that needs to be accessed by several different activities.
Should I share this object by making it static? As, for example, in the activity that initializes the database, I do this:
protected static appDatabase db;
Then others can access it through FirstActivity.db .
Another option is to create private appDatabase db objects in every action that he needs, but I suspect that opening multiple db objects to access the same stored data can be wasteful.
However, I am not too keen on java, so I ask - what is the preferred way to do this and why?
thanks
Jds
source share