GreenDaoHelper.java
935 Bytes
package com.cnlive.goldenline.dao;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;
/**
* Created by zuoxian on 15/9/7.
*/
public class GreenDaoHelper {
private static GreenDaoHelper instance;
private DaoSession daoSession;
public GreenDaoHelper(Context context) {
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "migutv-db", null);
SQLiteDatabase db = helper.getWritableDatabase();
DaoMaster daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
}
public static synchronized GreenDaoHelper getInstance(@NonNull Context ctx) {
if (instance == null)
instance = new GreenDaoHelper(ctx.getApplicationContext());
return instance;
}
@NonNull
public HistoryDao getHistoryDao(){
return daoSession.getHistoryDao();
}
}