SparseParcelableArraySerializer


public final class SparseParcelableArraySerializer implements KSerializer


A serializer for SparseArray. This serializer uses SavedState's API directly to save/load a SparseArray.

Note that this serializer should be used with SavedStateEncoder or SavedStateDecoder only. Using it with other Encoders/Decoders may throw IllegalArgumentException.

import androidx.savedstate.serialization.serializers.ParcelableArraySerializer
import androidx.savedstate.serialization.serializers.SparseParcelableArraySerializer

@Serializable
class MyModel(
    @Serializable(with = SparseParcelableArraySerializer::class)
    val sparseParcelableArray: android.util.SparseArray<android.os.Parcelable>
)

Summary

Public constructors

Public constructors

SparseParcelableArraySerializer

Added in 1.3.0-alpha06
public SparseParcelableArraySerializer()

Public methods

deserialize

Added in 1.3.0-alpha06
public @NonNull SparseArray<@NonNull Parcelabledeserialize(@NonNull Decoder decoder)

getDescriptor

Added in 1.3.0-alpha06
public @NonNull SerialDescriptor getDescriptor()

serialize

Added in 1.3.0-alpha06
public void serialize(
    @NonNull Encoder encoder,
    @NonNull SparseArray<@NonNull Parcelable> value
)