inlined initDatabase() and initView()