Backup and wipe your android phone properly before transferring or selling it to other person.
1. full backup
Before formatting your device, you should be aware of things that your date can be recovered with recovering tools. So you need to encrypt your data before wiping out.
Encrypt your data
If you encrypt your data before formatting your phone, it will be impossible to recover and decrypt. Make sure your device is fully charged before proceeding because encrypting process takes time.
1. Launch the settings app and locate the “Encryption” option under Security.
2. Tap “Encrypt phone.”
Perform a factory reset
Settings -> Backup & reset -> Factory data reset” and tap “Reset phone.” Now it is safe to sell your phone.