Retrofit and Room with default values

Viewed 33

in my project, I am getting the response below. I want to use this class for my room database as well. The saved variable was put in there by my, but problem is, every time I put an entry in my db, saved becomes false (which totally makes sense)

Is there any was for the value to only become false by default, during my api call, which means only if saved is null (since this variable is not included in my api's response)?

@Entity(
    tableName = "information"
)
data class Info(
    @PrimaryKey
    val id: Int,
    val img: String,
    val name: String,
    val status: String,
    var saved: Boolean = false
): Serializable
0 Answers
Related