I am making an app. There is an ActionBar with settings option. In it there is an EditTextPreference. How can I get the Text which the user writes there? I tried a lot of code, but don't work. Could somebody help me?
Here is my MainActivity:
public class MainActivity extends FragmentActivity implements
    ActionBar.TabListener, LocationListener {
public static FragmentManager fragmentManager;
ActionBar actionbar;
ViewPager viewpager;
FragmentPageAdapter ft;
boolean intervall=false;
boolean started;
static String intervalloption = "INTERVALLOPTION";
Intent intervalloptionintent = new Intent(intervalloption);
Bundle intervalloptionbundle = new Bundle();
Context mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewpager = (ViewPager) findViewById(R.id.pager);
    ft = new FragmentPageAdapter(getSupportFragmentManager());
    fragmentManager = getSupportFragmentManager();
    actionbar = getActionBar();
    viewpager.setAdapter(ft);
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionbar
            .addTab(actionbar.newTab().setText("Run").setTabListener(this));
    actionbar
            .addTab(actionbar.newTab().setText("Statistics").setTabListener(this));
    viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    });
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.share) {
        Toast.makeText(getApplicationContext(), "share", Toast.LENGTH_LONG).show();
        return true;
    }
    if (id == R.id.action_settings) {
        Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
        startActivity(intent);
        Toast.makeText(getApplicationContext(), "settings", Toast.LENGTH_LONG).show();
        return true;
    }
    if (id == R.id.exit) {
        Toast.makeText(getApplicationContext(), "exit", Toast.LENGTH_LONG).show();
        finish();
        System.exit(0);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
}
And this is SettingsActivity:
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
static String intervalloption = "INTERVALLOPTION";
Intent intervalloptionintent = new Intent(intervalloption);
Bundle intervalloptionbundle = new Bundle();
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    //addPreferencesFromResource(R.layout.preferences);
    getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    settings.registerOnSharedPreferenceChangeListener(this);
    Toast.makeText(getApplicationContext(), "Preference", Toast.LENGTH_LONG).show();
}
public static class MyPreferenceFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener
{
    @Override
    public void onCreate(final Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.layout.preferences);
    }
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (key == "walk") {
            String walktime = sharedPreferences.getString(key, "walk");
            Toast.makeText(getActivity(), String.valueOf(walktime), Toast.LENGTH_LONG).show();
            // do stuff
        }
    }
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key == "walk") {
        String walktime = sharedPreferences.getString(key, "walk");
        Toast.makeText(getApplicationContext(), String.valueOf(walktime), Toast.LENGTH_LONG).show();
        // do stuff
    }
}
}
 
     
    