Customizing PreferenceActivity or create my own?
I need screen to setup typical stuff. But I have couple requirements:
- Preferences stored in DB
- I need to have some preferences read/only if administrator sets them and prohibit user from changing (from server side)
So, I like built-in开发者_开发百科 functionality but want to save/load from DB and want to disable controls if needed.
Can I do stuff like this or I'm better off with my own activity and Dialogs?
Yes to both of those. You can extend a PreferenceActivity
and then override the getSharedPreferences()
method to return your own implementation of SharedPreferences
that saves data into the database instead of into the shared preferences XML. You can provide a preference XML just like you would in the "normal" case, you would just add some code to enable/disable the preferences that you need.
It will take a bit of work to figure out all the parts, but you will save time trying to implement the UI and deal with all the interactions.
See also this question.
精彩评论