Reputation: 1291
This question has been asked may times, but still no convincing answer. I have just one activity which loads different fragments, so don't want to create a preference activity to replace this one activity. Is it possible to create my own UI and save preferences within a fragment without using preference activity?
Upvotes: 0
Views: 378
Reputation: 4775
Absolutely, PreferenceActivity
is just a convenience to automate working with shared prefs changed by user actions. There is nothing stopping you from, let's say, creating a check box element and obtaining a SharedPreferences
object using your current context, and editing some prefs.
Also, if you have one activity just switching between fragments, you can also take advantage of a PreferenceFragment
Upvotes: 2