Back to project page android-mvc-framework.
The source code is released under:
Apache License
If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android_mvc.framework.db; //www . j a v a 2 s .c o m import java.io.File; import com.android_mvc.framework.common.FWUtil; import com.android_mvc.framework.db.schema.AbstractSchemaDefinition; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; /** * DB????????????? * @author id:language_and_engineering */ public class DBHelper extends SQLiteOpenHelper { // ????????? public static String DB_NAME = ""; // AP???????????????? // ????????????? private static String DB_FULL_PATH = ""; // ???????????? private static final int DB_VERSION = 1; // TODO: // DB?????????????? AbstractSchemaDefinition schemaDefinition; /** * ??????? */ public DBHelper(Context context) { super(context, DB_NAME, null, DB_VERSION); //this.context = context; } /** * ????????????????????????????? */ public void createSchemaIfNotExists( AbstractSchemaDefinition sd ) { schemaDefinition = sd; // ???????????????DB?????????????? // ?????????????????????????????onCreate?????????? // onCreate?????????????????????????????? getWritableDatabase().close(); // @see http://d.hatena.ne.jp/language_and_engineering/20111202/p1 // @see http://stackoverflow.com/questions/5024223/sqliteopenhelper-failing-to-call-oncreate // NOTE:close??????????????????????????????? } /** * ?????????? * ???????????????????????????????????????????????????? */ @Override public void onCreate(SQLiteDatabase db) { // ????????????????????????????????????????????????????? schemaDefinition.createAll( db ); /* // ????????????????????????????????????????????????????????????????? for( int i = 0 ; i < 10; i ++ ){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } */ FWUtil.d("DB?????????????"); } /** * ???????????? * ?????????????????????version????????????????????????????? */ @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO: //DBInitializer.exec_update(db, this); } /** * DB??? */ public void deleteDB() { FWUtil.d("DB?????????????"); new File(DB_FULL_PATH).delete(); FWUtil.d("DB????????????????"); } // G&S /** * DB?????????? */ public static void setDB_NAME(String db_name) { DB_NAME = db_name; FWUtil.d("????????DB??????" + DB_NAME); } /** * DB?????????????? */ public static void setDB_FULLPATH(String dbFullpath) { DB_FULL_PATH = dbFullpath; } }