getDir이 아직 존재하지 않으면 디렉토리를 생성한다는 것을 이해했습니다. 하지만 다음과 같이 충돌합니다.getDir에서 NullPointerException이 발생하는 이유는 무엇입니까?
File dir= getDir(file,Context.MODE_PRIVATE);
파일의 유형이 String입니다. 여기
12-29 21:56:09.456: ERROR/AndroidRuntime(631): java.lang.NullPointerException
12-29 21:56:09.456: ERROR/AndroidRuntime(631): at android.content.ContextWrapper.getDir(ContextWrapper.java:198)
를 코드입니다 : 로그 캣 보여줍니다 BTW
public class ReportHome extends Application{
public ReportHome(String message, String file){
…some code…
inf(tosend,file);
}
public void inf(String c, String file){
File dir= getDir(file,Context.MODE_PRIVATE);
: 올바르게 로그 캣 하나 개 이상의 라인을 포맷하는 트릭은 무엇인가?
예, "getback"이 있습니다 – michaelsmith
나는 조금 더 대답을 확장했습니다. 어떤 컨텍스트가 여기에 기초하지 않았을만한 이유가 있습니까? (활동의 내부입니까? 아니면 다른 곳입니까?) –