GreenDao数据库封装

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数据库封装)