# IpSecManager.SecurityParameterIndex

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

# SecurityParameterIndex

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/IpSecManager.SecurityParameterIndex "View this page in Java")  

```
class SecurityParameterIndex : AutoCloseable
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                     ||
| ↳ | [android.net.IpSecManager.SecurityParameterIndex](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#) |

This class represents a reserved SPI.

Objects of this type are used to track reserved security parameter indices. They can be obtained by calling android.net.IpSecManager#allocateSecurityParameterIndex and must be released by calling[close()](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#close())when they are no longer needed.

## Summary

|                                                                                                                   Public methods                                                                                                                    ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)     | [close](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#close())`()` Release an SPI that was previously reserved.  |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)       | [getSpi](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#getSpi())`()` Get the underlying SPI held by this object. |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#toString())`()` <br />                                  |

|                                                                                                                Protected methods                                                                                                                ||
|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finalize](https://developer.android.com/reference/kotlin/android/net/IpSecManager.SecurityParameterIndex#finalize())`()` Check that the SPI was closed properly. |

## Public methods

### close

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

```
fun close(): Unit
```

Release an SPI that was previously reserved.

Release an SPI for use by other users in the system. If a SecurityParameterIndex is applied to an IpSecTransform, it will become unusable for future transforms but should still be closed to ensure system resources are released.

|                        Exceptions                        ||
|-----------------------|-----------------------------------|
| `java.lang.Exception` | if this resource cannot be closed |

### getSpi

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

```
fun getSpi(): Int
```

Get the underlying SPI held by this object.  

### toString

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

```
fun toString(): String
```

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |

## Protected methods

### finalize

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

```
protected fun finalize(): Unit
```

Check that the SPI was closed properly.

|                         Exceptions                         ||
|-----------------------|-------------------------------------|
| `java.lang.Throwable` | the`Exception`raised by this method |