title: Flushing and SQLite database on android
body: <p>I have an android application using an SQLite database. I open the database when the application starts, but never close it as it is in constant use.</p>
  
  <p>What is the best way to tell the database to flush all its changes to permanent storage? Do I need to just close it and re-open or is there a more efficient way?</p>
  
  <p>My problem is that when testing on a phone, turning the phone off after a number of writes sometimes causes the database to loose the most recent updates when the application is restarted, which is obviously unacceptable for a database system. </p>
  
  <p>Since I cannot find out how to capture the application close event I cannot know when to manually close the database.</p>