Using Activity life cycle to handle database open and closing