Only close the database when the Application terminates

I have run into some issues with older Android devices (Gingerbread)
crashing when trying to run nested queries. The database is closed
even though we called openDB(). This change updates the queries
to just call db.getDB() when they need access to the DB, and leave
the closing of the database up to the Application when it terminates.