Adding try-catch to deal with null pointer error that occurs when trying to set the id of a databasable when the databse is null