How to reset a Samsung Galaxy S4 back to factory settings?
Follow the below procedure:
1 - From the Home-screen > tap Menu .
2 - Settings .
3 - Accounts .
4 - Backup and Reset .
5 - Factory Data reset
6 - You can also choose to format the SD card too!
7 - Select Reset device Delete All .
8 - The device will restart.
9 - Wait for the restore procedure to be completed.