Android 4.4 and below
Older versions of Android — Android 4.4 KitKat and older — have an integrated way to bypass your pattern, PIN, or other password if you forget it. Google removed this feature in Android 5.0 Lollipop, so you’ll have to use a different method if you have a device with a newer version of Android.
To find this feature, first enter an incorrect pattern or PIN five times at the lock screen. “Forgot pattern,” “forgot PIN,” or “forgot password” button will appear. Tap it. You’ll be prompted to enter the username and password of the Google account associated with your Android device.
Android 5.0 and up
This feature was removed in Android 5.0. Unfortunately, this means there’s no built-in way to simply reset your pattern, PIN, or password and gain access to your phone or tablet.
Android’s Smart Lock feature may be able to save you. For example, let’s say you’ve set up Smart Lock on your Android phone and have it automatically logged in when it’s on your home Wi-Fi. You can take your phone to that home Wi-FI network and it will automatically unlock for you, even if you can’t remember the normal unlock code.
Also on Samsung devices, if you’ve logged into the device with a Samsung account, you can go to the Samsung Find My Mobile website, log in with the same Samsung account, and use the “Unlock my screen” option to remotely remove your device’s lock screen.
If you’ve already unlocked your bootloader and installed a custom recovery, you may be able to use that environment to remove the code.
Factory-reset your Android smartphone or tablet
If you were unable to reset the device using one of the tricks above, you will have to perform a factory reset, wiping the device’s storage, and setting it up again from scratch.
If your device has a removable SD card, remove the SD card before performing the factory reset. Shut down your Android device, remove the SD card, and then continue.
Use Google Android Device Manager
If your device is Google’s Android Device Manager enabled, you can visit the Android Device Manager website and log in with the same Google account you use on that Android device. Select the device you’re locked out of and select “Erase” to remotely erase it. You’ll be able to set it up from scratch afterwards — the lock code will be removed, but the device will also be wiped.
Note that the “Lock” option in Android Device Manager will only allow you to set a new lock code if your phone or tablet doesn’t already have an unlock code; so it can’t be used to remove an existing lock code.
If you’ve enabled another remote phone or tablet-tracking service, you can probably use its website to remotely wipe your device, too.
If you haven’t enabled Google’s Android Device Manager on your phone or tablet, you can still factory-reset your phone or tablet even if you can’t unlock it.
To do this, you’ll need to boot into your device’s system recovery menu and wipe it from there. Turn the device off and turn it on while holding the correct buttons. For example, on the Nexus 4, press and hold the Volume Down and Power buttons at the same time. On the Nexus 5, press and hold the Volume Down, Volume Up, and Power buttons at the same time. Use the recovery menu to wipe the device.
On devices running Android 5.1, enter the username and password of the Google account that was previously associated with the device after doing this. This prevents someone else from resetting and using your device. However, you won’t need the old unlock code to regain use of your hardware