开发者

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

开发者 https://www.devze.com 2022-12-24 01:00 出处:网络
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 t

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

精彩评论

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

关注公众号