It's pretty difficult to get "hacked", as you put it, without your help. You must have done something to cause the problem, not that I'm accusing you of doing it deliberately.
Visiting a dodgy website, clicking links in eMails (NEVER do that), opening eMail attachments, or downloading a suspect app from the OS vendor's app store are the ways these things happen. None of them can happen without your helping it somehow.
You might want to spend a few hours researching best practices for users of your phone and it's OS.
Without educating yourself, it's bound to happen again. Even when people *are* educated ... every organization that was the victim of the latest ransom-ware attack on desktop systems last week train their staff on best practices, yet someone in each organization did exactly what they were taught never to do ... click on a link in an eMail from an unsafe and untrusted sender. That is the only way to become infected with the wannacry ransom-ware worm.