Wesley Wiser
Wesley Wiser

Reputation: 9851

How to display defaultValues the first time a PreferenceActivity is started?

I've defined my preferences in an xml file, preferences.xml. I've also got a SettingsWindow class which extends PreferenceActivity. I've set the android:defaultValue attribute on my preferences in the xml file but they don't appear the first time the app is launched. How do I load the default values defined in the xml file into the SettingsWindow the first time the activity is launched?

Upvotes: 1

Views: 833

Answers (1)

Wesley Wiser
Wesley Wiser

Reputation: 9851

Figured out what's going on. I had defined my preferences.xml file and associated PreferenceActivity without specifying defaults and ran that in the emulator. Later on, I added the defaultValue tags to the xml file. When I deployed to the emulator, it wasn't the first time the preferences had been loaded so the defaultValues were skipped. Deleting the app's data and uninstalling\reinstalling the app fixed the issue.

Upvotes: 1

Related Questions