title: How to add a preference programmatically from normal activity in Android?
body: <p>I need to add a preference from an activity witch does not extend PreferenceActivity, i tried this:</p>
  
  <pre><code>PreferenceCategory targetCategory = (PreferenceCategory)findPreference("kurse");
                      EditTextPreference neuerKursEintrag = new EditTextPreference(SettingsActivity.this);
                      neuerKursEintrag.setKey("kurs");
                      targetCategory.addPreference(neuerKursEintrag);
  </code></pre>
  
  <p>but it does not work, because android studio cannot resolve the method <code>findPreference(java.lang.String)</code></p>