无法保存我的preferences应用杀死后, [英] Can't save my Preferences after app killed
问题描述
你好,我想在我的Android应用程序实现一个设置页面。
我定义了一个XML preference文件,其中我实现的CheckBox preference和EditText上preference。
Hi I'm trying to implement a settings page on my Android App. I defined a xml Preference file where I implemented CheckBoxPreference and EditTextPreference.
所有的设置工作完全诡计运行的应用程序,但是当我杀了它,我失去所有的设置。
All the settings work perfectly wile running the app, but when I kill it I lose all the settings.
preference.xml文件:
<PreferenceCategory android:title="Connection">
<CheckBoxPreference
android:title="Auto Log-In"
android:summary="Auto connect "
android:key="autoLogIn"
android:enabled="true"
android:selectable="true"/>
<EditTextPreference
android:name="Server"
android:summary="Change the default server"
android:defaultValue="www.google.com"
android:title="Change server to:"
android:key="www.google.com" />
</PreferenceCategory>
preferences.class
public class Preferences extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);\
}
}
我如何使应用程序保存设置?
How do I make the app save the settings?
更新:
我做了一些测试,和虚拟设备上,并且在我的旧的HTC Legend采用Android 2.1的设置做工精细!但他们并没有对三星Galaxy S采用2.2 DROID工作!这是否有意义任何人???
UPDATE: I did some test, and on the Virtual device and on my old HTC Legend with android 2.1 the settings work fine! But they don't work on the Samsung Galaxy S with droid 2.2!! Does this make sense to anybody???
推荐答案
我解决了这个问题用的软复位的*我的三星Galaxy S的......不敢相信我高腰一整天在一个正确的code。
I solved the problem with a soft reset* of my Samsung Galaxy S... can't belive I waisted an all day on a correct code.
希望这将节省一些时间给别人。
马尔科
Hope this will save some time to others. Marco
*的软复位的:设置 - >高级 - >恢复出厂设置
*Soft reset: Settings -> Privacy -> Factory data Reset.
这篇关于无法保存我的preferences应用杀死后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!