Adding functions to retrieve Device and Contact objects from the
database.