Skip to content

Instantly share code, notes, and snippets.

@JavaDeveloper
Created October 22, 2012 10:39
Show Gist options
  • Save JavaDeveloper/3930852 to your computer and use it in GitHub Desktop.
Save JavaDeveloper/3930852 to your computer and use it in GitHub Desktop.
public class DatabaseHelper extends SQLiteOpenHelper {
private static DatabaseHelper mInstance = null;
private static final String DATABASE_NAME = "dbname.db";
private static final int DATABASE_VERSION = 1;
public static DatabaseHelper getInstance(Context ctx) {
// Use the application context, which will ensure that you
// don't accidentally leak an Activity's context.
if (mInstance == null) {
mInstance = new DatabaseHelper(ctx.getApplicationContext());
}
return mInstance;
}
private DatabaseHelper(Context ctx) {
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment