Last year our ground floor apartment had a fly infestation that the rest of the tenants in the building supposedly didn't experience. We have since moved (about 5 blocks) and have had no problems until now. Its been about a year between instances. Can flies move from one place to another? In plants maybe?
What kind of fly? Fruit flies - put all your fruit/veggies that are on the counter into the fridge (peel bananas and freeze is another option). There's good fruit fly trap designs on youtube.
Flour moths? Throw away all baked goods/cereal. Start again.
Shower flies? Spray antifungus stuff/bleack directly on all bathroom grouted seams and/or dig out the grout and re-grout or re-caulk. Also in bathroom wall/floor corners where moisture can exist.
Those giant black flies? Those are common in older houses. Just kill em - get fly strips - don't let em breed - but they'll come in through window edges from inside the walls of the house.
Wow, common house flies do like dirt and any organic matter they can lay there eggs in. If you use organic composit for your flowers the flies love this almost as much as horse poop. The only help we have found is purchasing fly predator larva online. We do this to our manure piles every 6-8 weeks. This is on a small horse farm you may Only need 1 small treatment with just a few in each pot. The predator larva eat the flys and don't bother plants. They have a short life span so we need to buy more, you may be good with 1 treatment of all your plants. Other than this there are the fly traps that the flys get in and the water at the bottom drowns them. When the bag or bottle is full they do make good compost. The last defense is the sticky nasty fly paper strips you hang from the ceiling. I don't like these but they are our last line of defense and work well but are ugly ang just yuk.