-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You can minimise the chances of your process being killed by running a
service that calls startForeground(). Android will only kill a process
containing a foreground service as a last resort.
https://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
https://developer.android.com/reference/android/app/Service.html#ProcessLifecycle
The service's onLowMemory() method will be called when the system is
low on memory, before killing any processes containing foreground
services, so that might be a good place to close the database cleanly.
https://developer.android.com/reference/android/app/Service.html#onLowMemory%28%29
However, running a service in the foreground isn't very polite to
other apps, which will be killed to make room for your app if
necessary. A more polite alternative would be to run a service that
doesn't call startForeground(), and to close the database cleanly if
either onLowMemory() or onDestroy() is called.
I don't recommend closing the database from the activity's onPause()
or onDestroy() methods, since those will be called whenever the user
switches to another activity or rotates the screen.
Cheers,
Michael
> -- You received this message because you are subscribed to the
> Google Groups "H2 Database" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
>
h2-database...@googlegroups.com. To post to this group,
> send email to
h2-da...@googlegroups.com. Visit this group at
>
http://groups.google.com/group/h2-database?hl=en. For more options,
> visit
https://groups.google.com/groups/opt_out.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQEcBAEBAgAGBQJRnl5cAAoJEBEET9GfxSfMQiMH/1d1O2+MzeWBgUWaULRvU6ey
prnTRuec2cnGZdZ/Vts9rAtXHpEuYcbUHcjvwdTTbzH8V3GjbnMiPYo57UTHitaG
o7mtt7tV5zP4tC9DdPukscZjGBjKHt1UjQe2X8qu0kfxFri+jG3lH5Slu2w1RoFO
MyJ4vGS5ybpeWXs+gH1VprFL8E58nZYeDR5EJAxTbHi/5dKYpkAvaheT0YDfV/dK
a/9bYe6n9QrII9cbeIvP7prWDLH5ucL+2WGKoMTjQ5fi6bJYCwyrwxOcCyyAgVdf
uNCdc/2s+bkywFTwnaqBQS5HuZGN7yPVOV74sAXGUtAI53nM4hMjorC+qgNd5Bg=
=O2W+
-----END PGP SIGNATURE-----