What is the smartest way, before selling a mobile phone, to be sure that no one will be able to access my data?
In my case we are talking about an LG G4.
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
The first thing you'd want to do is simply remove the SD card if any in use. If you intend on providing an SD card, purchase a new SD Card.
As suggested, the first step would be to encrypt your data (you can read up on this here), then perform a factory reset of the phone - I'd suggest performing this approximately 3 times. (1 should be sufficient, but 3 will determinately just make it a little harder to recover the data). You can find a pretty neat guide/explanation on this website.
Just to add onto Jay's answer, here is a basic guide on using ADB to encrypt your device. Note that the commands are noted to be:
user@laptop # adb root user@laptop # adb shell root@phone:/ # root@phone:/ # /system/bin/vdc cryptfs enablecrypto inplace PASSWORD
If you have rooted your phone (and intend to sell as is) you can install other applications that can encrypt certain directories, but I doubt you'll want to do this.
A factory reset is not enough. It just "disables" your data and doesn't really delete it. Some data restore tools can still restore the data after a normal reset.
The best way I know of is to encrypt the phone and then do a factory reset. The encryption will overwrite the unencrypted data, so that will be gone forever. Then after a reset, if the new user tries to restore the data, it just gets the encrypted data. (=useless)