basic question – I’m still learning Android – trying to create a seperate thread to do a DB query and having a problem. I’ve put my DB routines in their own class but can’t seem to access it from the thread:
public class TripsScreenActivity extends Activity implements OnClickListener {
public class dbThread extends AsyncTask<Cursor, Integer, Cursor> {
@Override
protected Cursor doInBackground(Cursor... arg0) {
// TODO Auto-generated method stub
// Link to WYWHApplication module
WYWHApplication wywh = (WYWHApplication) this.getApplication();
try {
Cursor tripList = wywh.getBasicList();
…but Eclipse is giving me the following error:
The method getApplication() is undefined for the type TripsScreenActivity.dbThread
Sorry, probably an obvious answer…any help gratefully accepted.
thisrefers to theAsyncTaskwhen used insidedoInBackground().You want to refer to your activity, so useTripsScreenActivity.this.getApplication()¹ instead ofthis.getApplication().¹ that’s called a “qualified this”