В моей папке res / xml хранится файл Preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory>
<Preference android:key="units_length" android:title="imperial"></Preference>
</PreferenceCategory>
</PreferenceScreen>
Вот как метод onCreate выглядит в моей деятельности:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.results);
// Get preferences
SharedPreferences preferences = getSharedPreferences("preferences", 0);
// Fetch the text view
TextView text = (TextView) findViewById(R.id.textView1);
// Set new text
text.setText(preferences.getString("units_length", "nothing"));
}
MyПриложение просто говорит «ничего».Что я тут не так делаю?