开发者

Customizing PreferenceActivity or create my own?

I need screen to setup typical stuff. But I have couple requirements:

  1. Preferences stored in DB
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜