Usually, viruses install in Android through third-party apps, and the virus can get deleted by uninstalling that app. But if your phone doesn’t get clean from the virus, then the factory reset will also get rid of it. However, you may lose all your other data too.