package app.jiyun.com.android_day07_greendao.app;
import android.app.Application;
import app.jiyun.com.android_day07_greendao.DaoMaster;
import app.jiyun.com.android_day07_greendao.DaoSession;
public class MyApplication extends Application {
private static MyApplication mApp;
private DaoSession mDaoSession;
public static MyApplication getMyApp() {
return mApp;
}
@Override
public void onCreate() {
super.onCreate();
mApp = this;
createDataBase();
}
private void createDataBase(){
//创建数据库
DaoMaster.DevOpenHelper openHelper = new DaoMaster.DevOpenHelper(mApp,"stu");
//用数据库框架进行包装
DaoMaster daoMaster = new DaoMaster(openHelper.getWritableDatabase());
//提供一个Session
mDaoSession = daoMaster.newSession();
}
public DaoSession getDaoSession(){
return mDaoSession;
}
}