To save boilerplate, I thought it would be a cool idea to make my Room Entity
a Serializable
and pass it around in an Intent
- but I had a bad feeling in doing this. Surely enough, this article and this SO post advise against doing so.
Thus I made a Serializable
data class
, and made it the sole column in the Entity
. Is this adequately addressing the concerns, or does this not really solve anything at all? Both classes lie in the same module.
Vehicle.kt
@Entity
data class Vehicle(
@PrimaryKey val data: VehicleData
)
VehicleData.kt
data class VehicleData(
val workArea: String,
val vehicleNumber: String
): Serializable