implemented a lot of catch code in the database, as Cursor's throw an IllegalStateException if the activity have been paused. Don't currently know what else to do.