Rebuild or Maintain a connection between android and MySQL database

I am creating an app with a html, css, js inside a webview, and also several databases to store data. My app is designed to be used for 10 to 11 hours each time.

A big problem was found that android will kill my app in background after leaving for a while. However, app gets killed will lead to a big problem as it means the whole task has to redo again. I have to maintain OR rebuild the connection between database and android to ensure my app can keep running smoothly.

I would like to know:
1.) is there any way to maintain the connection between database and android (e.g. put it in foreground service?) so that killing app will not affect the connection?

2.) can I ask android and js to rebuild the connection (e.g. synchronize the database?) between android and js after the app get killed by OS?