We had them REALLY bad this year. Fruit flies have about a 9-14 transit. This means, that from egg to death, is anywhere from 9-14 days. Their main source of food is obviously, anything fruit, but they are really attracted to smells of fermentation, because, in nature, that means rotting fruit.
So, all fruit and veg need to go into the fridge, or somewhere really sealed off from the rest of the world. Dry foods like flour, grains, ganulated sugar,etc, need to go into plastic buckets with tight sealing lids. Next, because they live in drains, you need to block off *all* drains in the house with plugs when not in use. This includes bathrooms, showers, etc. Small, blue-light bug zappers will attract the remaining ones and kill them off, but with no food sources, or breeding grounds, they die off in about a week. The sinks and drains are the biggest ones, because their maggots can easily live in there on all the bacteria. Only really harsh chemical will kill them in drains, but then that also gets into our ground water systems, or if you are on septic, will destroy your septic field.