Replaced hardcoded database name with the constant that hold the name of the database
close database, when results were not found
Allocate ContentValues once
Count only successful stored events