2

I have an Android app, in which I use Preferences. They are grouped with PreferenceCategory's.

My PreferenceCategory's have keys (android:key="setting"), like the ones in the official tutorial for settings (which I used myself to learn & make mine).

But is this a recommended way of doing preferences, a convention, or does is just happen to be that way in the tutorial? I don't have to refer to most of the categories in my code, just the preferences inside, so I see no real reason to have keys with all of them.

1 Answer 1

3

But is this a recommended way of doing preferences, a convention, or does is just happen to be that way in the tutorial?

No, you don't need to set keys for your PreferenceCategories, if you're not doing anything with them.

You can add Preferences to your PreferenceCategory by accessing it with findPreference(your_preference_category_key) and then calling addPreference(...) on it. But since you're not doing that you don't need to set any key for it.

1
  • Can you find any source for that? I don't require it, but it would just make an answer look a little more convincing. ;) Apr 23, 2014 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.