开发者

Is there a way to programmatically perform a factory reset on an Android device?

Understanding how incredibly dangerous this question is, I'd like to know if it is possible to programmatically issue a factory reset, as available in 开发者_JS百科Droid and G1. Does anyone know how this is implemented? Is this implemented using the standard Android SDK, a Motorola-specific function, or something else?


You may use the WipeData() method in DevicePolicyManager, which will erase all user data: http://developer.android.com/guide/topics/admin/device-admin.html

Available since Android 2.2

Close enough?


There is no means in the SDK to initiate a factory reset.


You can use the DevicePolicyManager method wipeData() to reset the device to factory settings. This is useful if the device is lost or stolen. Often the decision to wipe the device is the result of certain conditions being met. For example, you can use setMaximumFailedPasswordsForWipe() to state that a device should be wiped after a specific number of failed password attempts.

You wipe data as follows: Java:

DevicePolicyManager dpm;
mDPM.wipeData(0);

Kotlin:

private lateinit var dpm: DevicePolicyManager
dpm.wipeData(0)

Here is the site refrence

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜