In short, yes, a factory reset will usually remove viruses … but (there’s always a ‘but’ isn’t there?) not always. Due to the wide variety and ever-evolving nature of computer viruses, it’s impossible to say for sure that a factory reset will be the answer to curing your device from malware infection.
