Unlock Android Device using adb commands

My Android-Phone is locked because I put too many wrong patterns. When a wrong pattern is entered too often, your device is locked and asking to unlock it via google. You are a lucky guy, if it is locked with Wifi or data network on and of course you remember your google username and password. But if not, you have two possible solutions: 1. hard reset your device. 2. use adb commands.

If you use number 1 all your data are gone. Maybe you can restore it with a backup.

To use 2 you have to have enabled USB Debugging on the device before it is locked. If you have, and I have it always enabled on all my android devices, you can use the following solution to unlock your device.


  • PC or Laptop with a working OS on it (I use OSX, but it is working also on Unix and Windows)
  • Android SDK. You can get it at the developer site.
  • Connected android device via usb to your PC

adb commands

To run the adb-commands you have to change to the platform-tools directory in your android-sdk (/path/to/your/android-sdk/platform-tools).

Now you can use the following commands

adb devices # to verify that your device is identified
    adb shell
    cd /data/data/com.android.providers.settings/databases
    sqlite3 settings.db
    update system set value=0 where name='lock_pattern_autolock';
    update secure set value=0 where name='lock_pattern_autolock';
    update system set value=0 where name='lockscreen.lockedoutpermanently';
    update secure set value=0 where name='lockscreen.lockedoutpermanently';
    adb reboot

Now your device is unlocked. If not use adb shell rm /data/system/gesture.key.

I cleared lock patterns and removed the permanent lock from database. I have broken the security to unlock my device, but I saved my device and all data and I can use it again.

comments powered by Disqus