Android forensics

someone in my university sold her phone and the buyer started messaging her, somehow he got to know her sim number which was only known to her closest of friends. A simple online search says that android saves all this info including app usage and screenshots, google keyboard saves texts or whole lines typed and much much more in the root directory. Why is this information stored in the first place and is it being sent to google or the phone manufacturer in the background?if one wants to sell their device then how to format the phone so that this information in the root folder is not accessible by the buyer? how to enable full disk encryption in android to counter this? is trimming possible in android?