# RxSharedPreferencesMigrationBuilder

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

*** ** * ** ***


```
public final class RxSharedPreferencesMigrationBuilder<T extends Object>
```

<br />

*** ** * ** ***

RxSharedPreferencesMigrationBuilder for the RxSharedPreferencesMigration.

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigrationBuilder#RxSharedPreferencesMigrationBuilder(android.content.Context,kotlin.String,androidx.datastore.rxjava2.RxSharedPreferencesMigration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sharedPreferencesName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigration<@https://developer.android.com/reference/androidx/annotation/NonNull T> rxSharedPreferencesMigration )` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/DataMigration<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigrationBuilder#build()()` Build and return the DataMigration instance. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigrationBuilder<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigrationBuilder#setKeysToMigrate(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... keys)` Set the list of keys to migrate. |

## Public constructors

### RxSharedPreferencesMigrationBuilder

```
public <T extends Object> RxSharedPreferencesMigrationBuilder(
    @NonNull Context context,
    @NonNull String sharedPreferencesName,
    @NonNull RxSharedPreferencesMigration<@NonNull T> rxSharedPreferencesMigration
)
```

## Public methods

### build

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

```
public final @NonNull DataMigration<@NonNull T> build()
```

Build and return the DataMigration instance.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/DataMigration<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | the DataMigration. |

### setKeysToMigrate

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

```
public final @NonNull RxSharedPreferencesMigrationBuilder<@NonNull T> setKeysToMigrate(@NonNull String... keys)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html... keys` | the keys to migrate |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/rxjava2/RxSharedPreferencesMigrationBuilder<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | this |