Reading from SharedPreferences

To read values from SharedPreferences:

githubT06.03-Exercise-ReadingFromSharedPreferences

To read the value of the CheckBox from them SharedPreference and update the UI view based on that value.

// TODO (1) Change the name of default setup to setupSharedPreferences
private void setupSharedPreferences() {

    // TODO (2) Get a reference to the default shared preferences from the PreferenceManager class
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // TODO (3) Get the value of the show_bass checkbox preference and use it to call setShowBass
    mVisualizerView.setShowBass(sharedPreferences.getBoolean("show_bass", true));
}

Leave a comment