我的應用程序在下面的代碼中發生空指針異常崩潰。 我有res/xml/defaults.xml下的xml首選項文件 任何想法爲什麼它崩潰?Android ==>首選項?
public class Preference extends Activity {
public Preference()
{
}
public String getPreference(String key)
{
//it still crashes here
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
String result = settings.getString(key, null);
return result;
}
}
謝謝,我做你建議,我仍然得到一個nullPointerException。 我上面發佈了我的完整代碼,您是否看到問題? 謝謝 – aryaxt 2010-06-19 15:24:30