내 응용 프로그램이 아래 코드에서 널 포인터 예외로 인해 충돌합니다. 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