美文网首页
GreenDao数据库封装

GreenDao数据库封装

作者: 荀丽国 | 来源:发表于2017-07-04 11:31 被阅读0次

    public class GreenDaoHelper {

    private static GreenDaoHelper greenDaoHelper;

    private DaoMaster.DevOpenHelper devOpenHelper;

    public GreenDaoHelper(Context context) {

    devOpenHelper = new DaoMaster.DevOpenHelper(context, "books.db", null);

    }

    public static synchronized GreenDaoHelper openHelper(Context context) {

    if (greenDaoHelper == null) {

    synchronized (GreenDaoHelper.class) {

    if (greenDaoHelper == null) {

    greenDaoHelper = new GreenDaoHelper(context);

    }

    }

    }

    return greenDaoHelper;

    }

    public SQLiteDatabase getRead() {

    return devOpenHelper.getReadableDatabase();

    }

    public SQLiteDatabase gerWriter() {

    return devOpenHelper.getWritableDatabase();

    }

    }

    相关文章

      网友评论

          本文标题:GreenDao数据库封装

          本文链接:https://www.haomeiwen.com/subject/yjwthxtx.html