本文整理匯總了Java中org.greenrobot.greendao.database.DatabaseOpenHelper類的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseOpenHelper類的具體用法?Java DatabaseOpenHelper怎麽用?Java DatabaseOpenHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatabaseOpenHelper類屬於org.greenrobot.greendao.database包,在下文中一共展示了DatabaseOpenHelper類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initDatabase
import org.greenrobot.greendao.database.DatabaseOpenHelper; //導入依賴的package包/類
/**
* 初始化greenDao,這個操作建議在Application初始化的時候添加;
*/
public static void initDatabase(Context context) {
if (mDaoSession != null) {
return;
}
if (context == null) {
throw new IllegalArgumentException("You cannot start a load on a null Context");
}
DatabaseOpenHelper mHelper;
mHelper = new DaoMaster.DevOpenHelper(context.getApplicationContext(), DB_NAME);
/* if (BuildConfig.DEBUG) {
mHelper = new DaoMaster.DevOpenHelper(context.getApplicationContext(), DB_NAME);
} else {
mHelper = new MySQLiteOpenHelper(context.getApplicationContext(), DB_NAME);
}*/
Database db = mHelper.getWritableDb();
DaoMaster mDaoMaster = new DaoMaster(db);
mDaoSession = mDaoMaster.newSession();
}