Why did Cook know that Hawaii was a Sandwich Island?

Sandwich Islands was just the name that James Cook gave to Hawaii, not knowing the native name for the islands he named them in honor of his boss the fourth Earl of Sandwich who was the First Lord of the Admiralty.