I have a program that works on two devices for transferring files broken into parts, when sending from one device to another, for example, a picture, the number of bytes is received in the count variable, then I am going to connect the progressbar, the problem is saving the values, for example if the file weighs 20 kilobytes, I receive 20,000 parts, which I save using the update method, that is, I take a variable in the database and add new values to it at each iteration, in theory, progress should reach 100%, however, the update method does not saves some values from iterations, simply skipping them without saving, subsequently the progressbar value does not reach 100%, what am I missing?
Dao:
@Query("UPDATE FileItem SET progressDownload = :value WHERE uuid = :uuid")
suspend fun updateProgressDownload(uuid: String, value: Long)
RepositoryImpl:
override suspend fun updateProgressDownload(uuid: String, value: Long) {
fileDao.updateProgressDownload(uuid, value)
}
View Model:
val currentValueDataBase =
roomRepository.getItemByUuid(it)?.progressDownload
val addANewValueToThePrevious = currentValueDataBase?.plus(transport.count)
if (addANewValueToThePrevious != null) {
roomRepository.updateProgressDownload(it, addANewValueToThePrevious)
}
This is the log:
1