# RecoverySystem

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/os/RecoverySystem#nestedclasses)\|[Methods](https://developer.android.com/reference/android/os/RecoverySystem#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/os/RecoverySystem#inhmethods)  

# RecoverySystem

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/RecoverySystem "View this page in Kotlin")\|Java

`
public


class
RecoverySystem
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|---------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.RecoverySystem |

<br />

*** ** * ** ***

RecoverySystem contains methods for interacting with the Android recovery system (the separate partition that can be used to install system updates, wipe user data, etc.)

## Summary

|                                                                                                    ### Nested classes                                                                                                     ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [RecoverySystem.ProgressListener](https://developer.android.com/reference/android/os/RecoverySystem.ProgressListener) Interface definition for a callback to be invoked regularly as verification proceeds. |

|                                                                                                                                                                                                                                                                                   ### Public methods                                                                                                                                                                                                                                                                                    ||
|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static void` | ` `[installPackage](https://developer.android.com/reference/android/os/RecoverySystem#installPackage(android.content.Context,%20java.io.File))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[File](https://developer.android.com/reference/java/io/File)` packageFile) ` Reboots the device in order to install the given update package.                                                                                                                                                                                    |
| ` static void` | ` `[rebootWipeCache](https://developer.android.com/reference/android/os/RecoverySystem#rebootWipeCache(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Reboot into the recovery system to wipe the /cache partition.                                                                                                                                                                                                                                                                                 |
| ` static void` | ` `[rebootWipeUserData](https://developer.android.com/reference/android/os/RecoverySystem#rebootWipeUserData(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Reboots the device and wipes the user data and cache partitions.                                                                                                                                                                                                                                                                        |
| ` static void` | ` `[verifyPackage](https://developer.android.com/reference/android/os/RecoverySystem#verifyPackage(java.io.File,%20android.os.RecoverySystem.ProgressListener,%20java.io.File))`(`[File](https://developer.android.com/reference/java/io/File)` packageFile, `[RecoverySystem.ProgressListener](https://developer.android.com/reference/android/os/RecoverySystem.ProgressListener)` listener, `[File](https://developer.android.com/reference/java/io/File)` deviceCertsZipFile) ` Verify the cryptographic signature of a system update package before installing it. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### installPackage

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void installPackage (Context context, 
                File packageFile)
```

Reboots the device in order to install the given update package. Requires the[Manifest.permission.REBOOT](https://developer.android.com/reference/android/Manifest.permission#REBOOT)permission.  
Requires android.Manifest.permission.RECOVERY

<br />

|                                                                                                         Parameters                                                                                                         ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`     | `Context`: the Context to use <br />                                                                                                                                                                        |
| `packageFile` | `File`: the update package to install. Must be on a partition mountable by recovery. (The set of partitions known to recovery may vary from device to device. Generally, /cache and /data are safe.) <br /> |

|                                                                         Throws                                                                         ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if writing the recovery command file fails, or if the reboot itself fails. |

### rebootWipeCache

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void rebootWipeCache (Context context)
```

Reboot into the recovery system to wipe the /cache partition.

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

|                                                Throws                                                ||
|----------------------------------------------------------------------------|--------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if something goes wrong. |

### rebootWipeUserData

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void rebootWipeUserData (Context context)
```

Reboots the device and wipes the user data and cache partitions. This is sometimes called a "factory reset", which is something of a misnomer because the system partition is not restored to its factory state. Requires the[Manifest.permission.REBOOT](https://developer.android.com/reference/android/Manifest.permission#REBOOT)permission.

<br />

|                   Parameters                    ||
|-----------|--------------------------------------|
| `context` | `Context`: the Context to use <br /> |

|                                                                                Throws                                                                                ||
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)               | if writing the recovery command file fails, or if the reboot itself fails. |
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) | if the current user is not allowed to wipe data.                           |

### verifyPackage

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void verifyPackage (File packageFile, 
                RecoverySystem.ProgressListener listener, 
                File deviceCertsZipFile)
```

Verify the cryptographic signature of a system update package before installing it. Note that the package is also verified separately by the installer once the device is rebooted into the recovery system. This function will return only if the package was successfully verified; otherwise it will throw an exception. Verification of a package can take significant time, so this function should not be called from a UI thread. Interrupting the thread while this function is in progress will result in a SecurityException being thrown (and the thread's interrupt flag will be cleared).

<br />

|                                                                                                                                                   Parameters                                                                                                                                                    ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `packageFile`        | `File`: the package to be verified <br />                                                                                                                                                                                                                                                 |
| `listener`           | `RecoverySystem.ProgressListener`: an object to receive periodic progress updates as verification proceeds. May be null. <br />                                                                                                                                                           |
| `deviceCertsZipFile` | `File`: the zip file of certificates whose public keys we will accept. Verification succeeds if the package is signed by the private key corresponding to any public key in this file. May be null to use the system default file (currently "/system/etc/security/otacerts.zip"). <br /> |

|                                                                                  Throws                                                                                  ||
|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                                 | if there were any errors reading the package or certs files. |
| [GeneralSecurityException](https://developer.android.com/reference/java/security/GeneralSecurityException) | if verification failed                                       |