How to remove Any locked ( pattern / pin / password ) via TWRP Recovery
If Your Device Won’t Unlock At All
Here’s where things get really dicey. In some rarer cases, your most recent PIN will work at boot, but no PIN will work to unlock the screen–meaning you can’t access anything on your phone. Thankfully, this is fixable too–it just takes a few more steps.
First, boot back into TWRP’s recovery environment. It’ll likely ask you for a password–enter your most recent working PIN (the one you were using before you restored from backup). If you didn’t have a PIN, type in
default_password
. You’ll be greeted with the main TWRP window.
Then, head to Advanced > File Manager, and go to the /data/system folder. Scroll down and find the two files with the
.key
extension. Delete both of them (by tapping on the file and then tapping the “Delete” button). Then, delete all the files containing the word locksettings
.
So on my Nexus 5X, for example, I deleted the following files:
password.key
pattern.key
locksettings.db
locksettings.db-shm
locksettings.db-wal
Once you’ve deleted all the key and locksettings files, reboot your system. If it asks you to install SuperSU, choose “Do Not Install”.
You may be prompted for a PIN before your phone finishes booting. Once again, it should work with your most recent PIN–the one you were using before you restored from backup.
Once Android starts, your lock screen should appear, with no PIN or password prompt. Unlock your phone (yay!) and head to Android’s Settings. Scroll down and go to Security > Screen Lock. From there, you can choose a new PIN or password to lock your phone.
After doing so, that is the PIN or password you will use for everything from here on out.