Errors in PrefsLoadTask (Tutorial #13 ver.38)

48 Views Asked by At

I get the following 3 errors in the ModelFragment.java:

The method doInBackGround(Context...) of type ModelFragment.PrefsLoadTask must override      or implement a supertype method

The type ModelFragment.PrefsLoadTask must implement the inherited abstract method AsyncTask<Context,Void,Void>.doInBackground(Context...)   

Void methods cannot return a value  

Here is my sourcecode:

private class PrefsLoadTask extends AsyncTask<Context, Void, Void> {
    SharedPreferences localPrefs=null;

    @Override
    protected void doInBackGround(Context... ctxt) {
        localPrefs=PreferenceManager.getDefaultSharedPreferences(ctxt[0]);
        localPrefs.getAll();

        return(null);
    }

    @Override
    public void onPostExecute(Void Arg0) {
        ModelFragment.this.prefs=localPrefs;
        ModelFragment.this.prefsTask=null;
        deliverModel();
    }
}

As far as i can see the code is just like in the book. Also i have gone through all code that i have entered in this chapter. Can you see any errors her? The apps run ok after step #5 in this chapter.

1

There are 1 best solutions below

2
On

As far as i can see the code is just like in the book

No, it is not. It is doInBackground(), not doInBackGround() (notice the case of the g). Also, the return type must be Void, not void (notice the case of the V).