Are you thinking of trading in your smartphone, or selling your tablet? Did you upgrade to a new device and are now considering giving your old one to a friend or relative?
In all such cases, in order to protect your data, you need to know how to remove your data from the device in a way that the next user cannot restore your personal files. Simply deleting files does not do the job - there are tools that can easily recover your files; all "deleting files" does is mark the storage space used for the "deleted files" as available for other uses, but the files are not actually removed from your device until they are overwritten.
So how can you properly and securely wipe your device?
Step 1 - Remove the SD card or any other expansion card.
If you encrypted the card and want to be able to extract files from it using another device, turn off any encryption before removing it. If you run the Security app you should see a setting called "Encrypt SD Card" - which should be turned off.
Step 2 - If your device allows it, encrypt all of the files on your device's internal memory.
By doing so, if someone were able to recover any of your files, the contents would be encrypted and unusable. To encrypt, run the Android Settings app, select the Security option (on some devices this is called "Lock Screen and Security"), and enable the encryption option (sometimes listed as "Require Lock Screen" or "Encrypt Phone"). Not all phones offer this encryption, and some enable encryption by default.
Step 3 - Logout of your Google account
If your phone or tablet provider has an account (e.g., as Samsung does) log out of that account as well.
Step 4 - "Factory Reset" the phone
By doing so, you will erase your personal data from the device - but in an insecure fashion (as described above - since the data is not actually removed from storage, its storage space is just marked as available). To factory reset your phone go into the Settings app's "Backup and Reset" menu and select "Factory data reset." Before doing the reset make sure the phone is not configured to automatically restore files; make sure that the "Automatic Restore" in the same menu section is disabled.
Step 5 - Copy non-private files to fill up the entire memory.
Use large files to start (I use video files), then smaller ones once large ones will not fit anymore. You want to fill up the entire memory. Copying these files to the device overwrites the memory used before to store your personal files.
Step 6 - Factory reset again.
You can repeat steps 3 and 4 multiple times - but, for most users once is likely sufficient.