Many times you may require to factory reset your phone or android device, the reasons may be that you want to remove your main google account, or your phone has been locked and unable to unlock. There are also some other reasons e.g. your phone having some problems/issues related to OS e.g. frequent freeze and hanging and may be that you are continue facing problem of low memory.
If you are able to access your device you can do factory reset of your device using settings, go to settings , now about device where you will found factory data reset option. Some devices have this option under location & security and some have under privacy settings. After factory reset all your contacts, sms, apps (downloaded via play store), data stored in your phone memory like google map offline cache & tiles , emails etc. will be deleted. So take first backup of all your important data and do the factory reset.
How to hard reset your android device – In case you are not able to unlock your device due to may wrong patterns or wrong pin, your device will be locked and require your Google account user name and password. But this is a problem with Google codes that still there is no solution that how to enable mobile data or wifi in case you require to access google account information as this require a working data connection to check with server. If you are lucky and your mobile data is enabled than you can unlock using google account information other wise you have to hard reset your device. ( see my previous post how to unlock your device using Android lost free apps).
For hard reset switch off your device , if unable to switched off than remove battery and again insert. Now press and hold volume down button and then press power button to switched on your device. When switched on you will reach recovery options of your device. Now move between menus using volume keys and select option using power key. Here you will found the option of clear data/factory reset not choose this option and confirm using power button. After completion reboot your device.
Some device may invoke this recovery menu by using power+vol dn button as like Samsung Galaxy Tab 2(7.0).