Created
October 22, 2012 10:40
-
-
Save JavaDeveloper/3930857 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 DatabaseHelper extends SQLiteOpenHelper { | |
private static DatabaseHelper instance = null; | |
private static final String DATABASE_NAME = "dbname.db"; | |
private static final int DATABASE_VERSION = 1; | |
public synchronized static DatabaseHelper getInstance(Context ctx) { | |
// Use the application context, which will ensure that you | |
// don't accidentally leak an Activity's context. | |
if (instance == null) { | |
instance = new DatabaseHelper(ctx.getApplicationContext()); | |
} | |
return instance; | |
} | |
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