just added a Preference-Screen into my app. I want to load and store the given values into my sqlite db. I do not know how to solve that, because I dont know how to access the fields in the oncreate of my method, they have no android:id field but an android:key
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Preferences">
<PreferenceCategory
android:title="@string/program_options">
<CheckBoxPreference
android:key="pref_opt1"
android:title="@string/autoLogin"
android:summary="@string/autoLoginDescription"
android:defaultValue="true"
/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/program_informations">
<ListPreference
android:key="pref_type"
android:title="Type"
android:summary="Select item from array"
android:entries="@array/types"
android:entryValues="@array/types_values"
android:defaultValue="1"
/>
<EditTextPreference
android:key="pref_text"
android:title="Input text"
android:summary="Tap to enter some text"
android:dialogTitle="Enter text"
/>
</PreferenceCategory>
<Preference
android:title="Visit us"
android:summary="SRS-Management GmbH">
<intent
android:action="android.intent.action.VIEW"
android:data="http://paperdynamix.de/" />
</Preference>
</PreferenceScreen>
and my Activity where i want to access the fields
package de.srs.android.pdixuploader.activies;
import de.srs.android.pdixuploader.R;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.widget.CheckBox;
public class Prefs extends PreferenceActivity {
private CheckBox autoLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//here I want to read and prefill the values of the fields
addPreferencesFromResource(R.layout.preferences);
}
}
Thanks