You go to settings, then factory data reset and you click, erase all data.This is possible only if you're using android. You will erase all the data completely including the applications.
Also, you can format your phone.This too loses all the data in the phone.If you have access to a computer, then you can try this out.
I prefer using the first method but if it doesn't work, you can try the second method.