GreenDao的APP——Android

2018-01-13 11:10:07来源:oschina作者:津乐人点击

分享

public class MyApplication extends Application {private static MyApplication application;


private DaoSession mDaoSession;


public static MyApplication getApplication() {return application;}


@Overridepublic void onCreate() {super.onCreate();//完成Application的初始化application = this;createData();}


//操作数据库private void createData() {//第一步创建一个数据库DaoMaster.OpenHelper openHelper = new DaoMaster.DevOpenHelper(application, "stu.db");SQLiteDatabase sqLiteDatabase = openHelper.getWritableDatabase();//第二步用数据库框架来包装数据库DaoMaster daoMaster = new DaoMaster(sqLiteDatabase);//第三步生成Session对象mDaoSession = daoMaster.newSession();}


public DaoSession getDaoSession() {return mDaoSession;}


}

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台