How can I do factory reset using adb in android?

Prashant picture Prashant · Feb 4, 2013 · Viewed 204.2k times · Source

How can I do the factory reset in android using ADB command? I had used adb reboot recovery command to get reset. But third party applications couldn't be cleared somehow.Is it correct way to achieve using ADB?

Actually, I want to do factory reset android devices through java code. What can be solution here?

Answer

0x8BADF00D picture 0x8BADF00D · Feb 17, 2016

You can send intent MASTER_CLEAR in adb:

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

or as root

adb shell  "su -c 'am broadcast -a android.intent.action.MASTER_CLEAR'"