Created
May 23, 2012 01:18
-
-
Save alexjlockwood/2772709 to your computer and use it in GitHub Desktop.
Singleton Database #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainApplication extends Application { | |
/** | |
* see NotePad tutorial for an example implementation of DataDbAdapter | |
*/ | |
private static DataDbAdapter mDbHelper; | |
/** | |
* Called when the application is starting, before any other | |
* application objects have been created. Implementations | |
* should be as quick as possible... | |
*/ | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
mDbHelper = new DataDbAdapter(this); | |
mDbHelper.open(); | |
} | |
/** | |
* Called when the application is stopping. There are no more | |
* application objects running and the process will exit. | |
* Note: never depend on this method being called; in many | |
* cases an unneeded application process will simply be killed | |
* by the kernel without executing any application code... | |
*/ | |
@Override | |
public void onTerminate() { | |
super.onTerminate(); | |
mDbHelper.close(); | |
mDbHelper = null; | |
} | |
public static DataDbAdapter getDatabaseHelper() { | |
return mDbHelper; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment