package com.casic.endoscope.utils import com.casic.endoscope.base.BaseApplication import com.casic.endoscope.bean.GasValueBean class DataBaseManager private constructor() { companion object { //Kotlin委托模式双重锁单例 val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { DataBaseManager() } } private var gasValueBeanDao = BaseApplication.get().getDaoSession().gasValueBeanDao fun loadAll(): List<GasValueBean> { return gasValueBeanDao.loadAll() } fun saveGasDensity(density: Int, currentTime: String) { val bean = GasValueBean() bean.value = density bean.time = currentTime gasValueBeanDao.insert(bean) } }