I want to use Context in the static class below in the do in background method. I have tried parsing context in the constructor and also creating an instance of the class but every time I get this error :
Attempt to invoke virtual method java.io.File android.content.Context.getCacheDir() on a null object reference
public static class PopulateDbAsyncTask extends AsyncTask<Void, Void,
Void> {
private PicDao picDao;
Context context;
public PopulateDbAsyncTask(PictureDataBase db, Contex context) {
picDao = db.picDao();
this.context = context;
}
@Override
protected Void doInBackground(Void... voids) {
RequestQueue mRequestQueue = Volley.newRequestQueue(context);
return null;
}
}