class NewsApplication : Application() {
private var sqlHelper: SQLHelper? = null
/** 获取数据库Helper */
fun getSQLHelper(): SQLHelper {
if (sqlHelper == null) {
sqlHelper = SQLHelper(instance)
}
return sqlHelper as SQLHelper
}
companion object {
var isIsLogin = false
//获取单例
@JvmStatic lateinit var instance: SportsApplication
private set
}
}
//调用
SportsApplication.getInstance()
SportsApplication.getInstance().getSQLHelper()
网友评论