开发者

Added preferences dynamically that will last over sessions

I have preference defined in xml, and I do this addPreferencesFromResource(R.xml.preferences1); to create the pref activity. But in code (dynamically) at runtime somethimes(depends on busyness logic) I add more items like this

CheckBoxPreference c=new CheckBoxPreference(this);
            c.setKey("asdasd");
            c.setTitle("asd");
            getPreferenceScreen().addPreference(c);

This works great and everything is fine(the state is sa开发者_开发技巧ved corectlly and it stays persistent) until I restart the phone. When I restart the phone this newly added item is lost. And only items from the xml file are shown in the prefereceActivity.

My question is what should I do to have this items even when the user restart the phone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜