2

I am having trouble in room database.

Please check my class named User. Now my query is, I dont want to update or insert single column if it comes null from API that means if "friendName (which is my one of the column)" is null from API then dont update or insert and If "friendName" has some value then update or insert that value.

I don't want to put @ignore annotation becuase when "friendName" will have some value at that time I want to update or insert that value.

Please help me.

@Entity(
tableName = "User",
indices = [Index(value = ["uid"], unique = true)]) class User {

@PrimaryKey(autoGenerate = true)
var id: Int = 0

@SerializedName("name")
var userName: String? = null

@SerializedName("uid")
var uid: Int? = -1

@SerializedName("friendName")
var friendName: String? = null }
Arjun Solanki
  • 236
  • 1
  • 11

0 Answers0