How to retrieve forgotten password in Samsung Galaxy S5

A friend of mine asked me if I knew how to restore his password on his Samsung Galaxy S5. I didn’t know what to answer because I haven’t used an S5. But I thought an easiest way how to get into his phone is by resetting it to its factory default settings, but doing so will lose its data and personal files, including apps manually installed. He didn’t want to lose all his personal files.

So I thought, aren’t all Android phones the same? Whether this be a Samsung Galaxy S5 or Nexus or HTC.