Whenever I try to add this line it crashes my app. Am I not putting it in the right spot?

    preferences.registerOnSharedPreferenceChangeListener(myActivity.this);

Here is my class

class Simulation extends View {

    // I declare my program variables here
    public Simulation(Context context) {
        super(context);
        // get the preferences
        SharedPreferences preferences = PreferenceManager
                .getDefaultSharedPreferences(context);
        preferences
                .registerOnSharedPreferenceChangeListener(myActivity.this);
        String storedPreference = preferences.getString("nPref", "0");
    }

    public void onSharedPreferenceChanged(
            SharedPreferences sharedPreferences, String key) {
        Log.i(TAG, "preferences changed!");
    }
}

Thanks!

Edit
Report