In many cases, the lock screen password has been forgotten due to our negligence. There is also no USB debugging turned on, and there is data to keep in the built-in storage. We need to remove the lock screen password without clearing the data. Next we'll show you how to do it.
Precautions
The first thing to note is that this method cannot be used for devices that are already bound to data encryption. For example, Motorola, set the input lock screen password to start the device, this method is no longer applicable. The reason is that this type of device uses a lock screen password to encrypt the data partition, which prevents the data partition from being modified.
For Android
Android 7.0+
Tested Models
Moto Z Android 7.0
Method
Use the search engine to find the TWRP Recovery that is right for your device and swipe in.
To enter TWRP Recovery, use the adb shell command to delete the following files:
rm /data/system/locksettings.dbrm /data/system/locksettings.db-SHMRM /data/system/locksettings.db-walrm /data/system/gatekeeper.password.keyRM /data/system/gatekeeper.pattern.key
Or you can use the file Manager that comes with TWRP and delete it manually.
After the deletion, the direct boot into the system, sliding lock screen will be able to enter the system.
Android 7.0 Retention data to remove lock screen password method