I've created an EditTextPreference and now I want to get the value from any other activity. I've been trying a lot of things but I cannot get it working. Where is this value stored? How can I retrieve it?
EDIT: I want to get the value from a different activity, not the Preferences
activity.
settings.xml
<EditTextPreference
android:title="EditText1"
android:key="edit1"
android:defaultValue="0"
android:dialogIcon="@drawable/fleetespiar"
android:inputType="number" />
Settings.java
(How to do this in a different activity)
Preference edit1= findPreference("edit1");
EditTextPreference editt1 = (EditTextPreference) edit1;
System.out.println(String.valueOf(editt.getText().toString()));
First you need to create an instance of SharedPreferences
, then you can call getString()
on it, specifying the key for the value.