Search code examples
javaandroidunhandled-exception

How to test unhandled exception?


I have an Android app for which I would like to save an unhandled exception into the Sqlite DB. I have created all the functionality for saving Error messages into the DB.

My question is, how do I throw unhandled exception?

When I try to do throw new Exception("Save me intodb"), this doesn't work, because I am forced to surround it with try catch.

Any idea how can I actually kill my Android app?


Solution

  • Answer from @Joop Eggen in the comments is correct

    "Runtime exceptions should do; throw new IllegalStateException();"