Which phase will run if my app crash on android?

Hey i want to make some method that work when the app get stopped/not responding/crash. This method will make the SQLite database have the actual values even the app get crash or stop working.

I want my method work when my app crash or accidentally closed, so i can keep the value on my database actual. What should i do ?

In which phase i should put this method ? onPause?onStop?onRestart?or onDestroy?

Thanks in advance.