Created
September 6, 2014 07:54
-
-
Save vuhung3990/51f6d50a05ff408f2f5e to your computer and use it in GitHub Desktop.
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 DatabaseHelper { | |
private Context context; | |
private SqliteHelper sqlite; | |
private String TB_NAME; | |
private String TB_STRUCT; | |
public DatabaseHelper(Context context, String DbName, String TB_NAME, String TB_STRUCT) { | |
this.context = context; | |
this.TB_NAME = TB_NAME; | |
this.TB_STRUCT = TB_STRUCT; | |
sqlite = new SqliteHelper(context, DbName, null, StaticVar.DB_VERSION, | |
this.TB_NAME, this.TB_STRUCT); | |
} | |
public void insert() { | |
// TODO: | |
} | |
public void update() { | |
// TODO: | |
} | |
public void delete() { | |
// TODO: | |
} | |
public SQLiteDatabase getSqliteDb() { | |
return sqlite.getWritableDatabase(); | |
} | |
private class SqliteHelper extends SQLiteOpenHelper { | |
private String TB_NAME; | |
private String TB_STRUCT; | |
public SqliteHelper(Context context, String name, | |
CursorFactory factory, int version, String TB_NAME, | |
String TB_STRUCT) { | |
super(context, name, factory, version); | |
this.TB_NAME = TB_NAME; | |
this.TB_STRUCT = TB_STRUCT; | |
} | |
@Override | |
public void onCreate(SQLiteDatabase db) { | |
db.execSQL("CREATE TABLE " + TB_NAME + " (" + TB_STRUCT + ")"); | |
} | |
@Override | |
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |
db.execSQL("DROP TABLE IF EXISTS " + TB_NAME); | |
onCreate(db); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment