I tried everything, this Using Application context everywhere? and few things more and nothing works.
I need the application context in my DatabaseException class which extends Exception.
I need it because I want to check some sharedpreferences
when the exceptions are launched.
The code basically is this:
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);
of course this doesn't work. So... please, somebody can help me?