나는이 모든 것을 시도했다.이 Using Application context everywhere? 그리고 몇 가지 더 효과가있는 것은 아무것도 없다.예외를 확장하는 클래스에서 컨텍스트를 얻는 방법
Exception을 확장하는 DatabaseException 클래스에 응용 프로그램 컨텍스트가 필요합니다. 예외가 시작될 때 sharedpreferences
을 확인하고 싶기 때문에 필요합니다.
public class DatabaseException extends Exception {
private static final long serialVersionUID = 1L;
DatabaseException(){
super();
}
DatabaseException(String s){
super(s);
}
public DatabaseException (String s, Throwable t){
super (s,t);
kindOfException(t.getCause(), s);
}
DatabaseException (Throwable t){
super (t);
kindOfException(t.getCause(), null);
}
...
private void createLog() {
Log.d("Database Exception","On Create Log");
String listLogs;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DatabaseException.class.context);
물론이 작동하지 않습니다 코드는 기본적으로이입니다. 그래서 ... 제발, 누군가 나를 도울 수 있니?
클래스 및 컨텍스트 매개 변수에 컨텍스트 필드를 생성자에 추가하십시오. – Yahor10