Can’t add parameter ‘this’

make sure WeatherDBHelper constructor receieve Context as param

Public class WeatherDBHelper{
     Context context;
     public WeatherDBHelper(Context context){
         this.context = context;
     }
     ....
}

EDIT

The WeatherDBHelper only receive Context as param. QueryUtils dont have the Context type.

it can be done where add context in QueryUtils class

Context context;
private WeatherDBHelper weatherDBHelper;
public QueryUtils(Context context){
     this.context = context;
     weatherDBHelper = new WeatherDBHelper(context); 
}

use in MainActivity

QueryUtils qt = new QueryUtils(this);

Leave a Comment