Fruit flies are of concern both as nuisance pests and as serious contaminators of food.  Though the native habitat of these flies is a tropical climate, this pest has been introduced to almost every climate and region of the world. They are common in homes, restaurants, supermarkets and wherever else food is allowed to rot and ferment. Tomatoes, melons, squash, grapes and other perishable items brought in from the garden are often the cause of an infestation developing indoors. They are also attracted to rotting bananas, potatoes, onions and other unrefrigerated produce purchased at the grocery store. But they also will breed in drains, garbage disposals, empty bottles and cans, trash containers, mops and cleaning rags.
Adults are about 1/8 inch long and usually have red eyes. The front portion of the body is tan and the rear portion is black. Fruit flies lay their eggs near the surface of fermenting foods or other moist, organic materials. Once the life cycle begins, the larvae feed near the surface of your fruit and vegetables, continuing the cycle of contamination. 
The primary control for fruit flies is sanitation. Prior to setting any traps for existing flies, the best way to avoid problems with them is to eliminate sources of attraction. Keep fruit stored in the refrigerator, rinse and drain bottles and cans that are to be recycled, and dispose of any garbage indoors. A single rotting potato or onion forgotten at the back of a closet, or fruit juice spillage under a refrigerator can breed thousands of them. So can a recycling bin stored in the basement which is never emptied or cleaned. 
Once you have rid your home of any possible fruit fly attractants use a trap to capture and kill fruit flies. It is recommended to use a non-toxic food-based liquid that lures the flies inside the trap. Once inside, they cannot escape to breed or feed.
Discovered in Florida in 1929, the Mediterranean fruit fly (aka the MedFly) was thought to have been eradicated in the United States by 1930 but reappeared in 1956 and in the early 1960s and again, in California, in the 1980s. Because of this pest, worldwide quarantine laws were formed to regulate the entry of fruits into countries. The Mediterranean fruit fly is currently found in Hawaii. California, Florida and Texas are considered at high risk. The Mediterranean fruit fly lays as many as 500 eggs in citrus fruits (except lemons and sour limes), making them inedible. It has been recorded to have infested a wide range of commercial and garden fruits, nuts and vegetables, including: apples, avocados, bell peppers, citrus, melons, peaches, plums and tomatoes. The USDA division of Animal and Plant Health Inspection Service is the governing body that inspects and regulates fruit imports into the United States.