Summarize this article:

On the home screen, press the Menu key, and then touch the Settings app to open it. In the Settings app, touch the Privacy option, and then touch Factory data reset. On the Factory data reset screen, you can choose whether to erase the phone's internal SD card or not. Touch the Format USB storage option check box to add or remove the check.  If the option is checked, it will erase the internal SD card. If the option is unchecked, it will not erase the internal SD card. Once you reset the phone, you will not be able to recover the data from the phone. Touch Reset phone, and then touch Erase everything. The Samsung Galaxy S2 will begin the reset process. Do not turn off the phone while it is resetting.
Open the Settings app. Start resetting the phone. Choose whether to erase the internal SD card. Reset the phone.