# RxSharedPreferencesMigrationBuilder

# RxSharedPreferencesMigrationBuilder

Artifact:[androidx.datastore:datastore-rxjava3](https://developer.android.com/jetpack/androidx/releases/datastore)  
[View Source](https://cs.android.com/search?q=file:androidx/datastore/rxjava3/RxSharedPreferencesMigration.kt+class:androidx.datastore.rxjava3.RxSharedPreferencesMigrationBuilder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder "View this page in Java")

<br />

```
class RxSharedPreferencesMigrationBuilder<T : Any?>
```

<br />

*** ** * ** ***

RxSharedPreferencesMigrationBuilder for the RxSharedPreferencesMigration.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                             ### Public constructors                                                                                                                                                                                                                                                                                                                                                                              |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<T : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[RxSharedPreferencesMigrationBuilder](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder#RxSharedPreferencesMigrationBuilder(android.content.Context,kotlin.String,androidx.datastore.rxjava3.RxSharedPreferencesMigration))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` sharedPreferencesName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` rxSharedPreferencesMigration: `[RxSharedPreferencesMigration](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigration)`<T>` `)` |

|                                                                   ### Public functions                                                                    |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DataMigration](https://developer.android.com/reference/kotlin/androidx/datastore/core/DataMigration)`<T>`                                                | [build](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder#build())`()` Build and return the DataMigration instance.                                                                                                                       |
| [RxSharedPreferencesMigrationBuilder](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder)`<T>` | [setKeysToMigrate](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder#setKeysToMigrate(kotlin.Array))`(vararg keys: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Set the list of keys to migrate. |

## Public constructors

### RxSharedPreferencesMigrationBuilder

```
<T : Any?> RxSharedPreferencesMigrationBuilder(
    context: Context,
    sharedPreferencesName: String,
    rxSharedPreferencesMigration: RxSharedPreferencesMigration<T>
)
```  

## Public functions

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)  

```
fun build(): DataMigration<T>
```

Build and return the DataMigration instance.  

|                                                  Returns                                                   |
|------------------------------------------------------------------------------------------------------------|--------------------|
| [DataMigration](https://developer.android.com/reference/kotlin/androidx/datastore/core/DataMigration)`<T>` | the DataMigration. |

### setKeysToMigrate

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0)  

```
fun setKeysToMigrate(vararg keys: String): RxSharedPreferencesMigrationBuilder<T>
```

Set the list of keys to migrate. The keys will be mapped to datastore.Preferences with their same values. If the key is already present in the new Preferences, the key will not be migrated again. If the key is not present in the SharedPreferences it will not be migrated.

This method is optional and if keysToMigrate is not set, all keys will be migrated from the existing SharedPreferences.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|---------------------|
| `vararg keys: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the keys to migrate |

|                                                                          Returns                                                                          |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|------|
| [RxSharedPreferencesMigrationBuilder](https://developer.android.com/reference/kotlin/androidx/datastore/rxjava3/RxSharedPreferencesMigrationBuilder)`<T>` | this |