I have a standart long field
@PrimaryKey(autoGenerate = true)
val id:Long
But it is filled in the process and has a random value. If I try to add it to the database through the DAO, then the id is not overwritten by autoGenerate sqlite engine
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(i:MyTypeObject)
If I do this type field nullable its does not work too
@PrimaryKey(autoGenerate = true)
val id:Long?
There is a way that any value that would be in the id field is forcibly converted to autoincrement value in db?
I recive data from repository livedata. In viewmodel
private val db = CurrencyDatabase.getInstance(getApplication())
private val dao = db!!.nalDao()
private val service = Executors.newFixedThreadPool(1)
fun addBook(book: CurrencyItem)
{
service.submit {
dao.insert(book)
}
}