You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Helper(context: Context) : SQLiteOpenHelper(context, DBNAME, null, DBVERSION) {
companion object {
private val DBNAME = "myDb"
private val DBVERSION = 1
}
-->this class will take context argument but in fragment it is showing error for "context","activity","this".. i have tried all the things but not be able to resolve the error
HomeFragment.kt->
class HomeFragment : Fragment() {
companion object {
const val KEY = "data"
}
val helper = Helper(context) //getting error-> Required:Context , Found:Context?
The text was updated successfully, but these errors were encountered:
I had the same problem as you. the solution is using magic variable: ctx. I called it "magic", because I dont know where it came from. It is a context, enough to initialize the db helper
Helper.kt->
-->this class will take context argument but in fragment it is showing error for "context","activity","this".. i have tried all the things but not be able to resolve the error
HomeFragment.kt->
The text was updated successfully, but these errors were encountered: