The best way to prevent this is by using a VPN (Virtual Private Network) when connecting to any public Wi-Fi. A VPN makes a secure tunnel that encrypts your data. But just like a home security system, if somebody has malicious intent and wants in bad enough, there is still a chance that they may get inside. However chances are they will go to the next house that doesn’t have that home security sign out front. Feel free to search the internet for VPN apps or software. Here are a couple of recommendations.
Hotspot Shield Free Privacy & Security VPN Proxy