Correct datatypes handling, added database opening in main activity