Magnetic Fields in Earth-like Exoplanets and Implications for Habitability around M-dwarfs