我的应用程序在下面的代码中发生空指针异常崩溃。 我有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