Reputation: 9471
I am writing my own logger that stores all the entries into a SQLite database using Sugar ORM. I can do normal log.e, log.d, log.i just fine, but in the event the app crashes I want my logger to be able to get the exception message and store it into the SQLite.
How would I get the exception message so I can store it into my SQLite database before the app crashes?
Thanks!
Upvotes: 0
Views: 232
Reputation: 9179
Use try-catch and all other exceptions you can log like this example shows:
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
_logger.logUncaughtException(e);
}
});
Upvotes: 1