Are you planning to return, resell or giving your phone to a service centre?. Make sure you securly wipe your device so that others won't get access to your data.
There is a factory reset option in Android, but it just formats the partions, that won't make sure that your data is not retrievable. Infact, it not difficult to recover data from formatted partitions. Anyone with basic computer knowledge might be able to do it.
0. Backup your device
If you are giving your phone to a service centre, you probably should make a backup first. (This method works only in 4.4 and above)
$ adb backup -all -apk -shared
to backup data locally, to a file backup.ab. And use
$ adb restore backup.ab
to restore data, when you get your device back.
Follow the steps to make sure that your data is not retrievable.
1. Encrypt your device.
In android, you can encrypt by going to
Settings -> Security. I recommend you to keep your device encrypted even if you are not planning to sell your device.
2. Factory reset your device
Make sure you do this after encrypting the device, to make it more effective. Option to format/factory reset is changes based on your device, android version and manufacturer. Most probably it will be a direction option in
Settings -> Backup and reset.
3. Zero Fill
Zero fill is the method in which we fill garbage or zeros in the disc, which reduces the possiblity of recovering old data. There are several apps to do that. I have used Secure Wipe before, which will sanitize the unused space. Make sure you do not use your phone while this process is ongoing.
4. Last step
Repeat step 2 and 3 as much as you can. This sounds like a noob suggestion, but trust me, it worth it. Also, try different apps for zero fill.