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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s