I want to add the value for pb and since including pb_value into the entity, the application crashes. I am new to learning room and I am not sure of the correct way to incorporate the extra item into the database.
E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_0
java.lang.RuntimeException: Exception while computing database live data.
at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:139)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:119)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:142)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:409)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:92)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:53)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:452)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:275)
at androidx.room.RoomDatabase.query(RoomDatabase.java:304)
@Entity(tableName = "pb_table")
data class Pb(@PrimaryKey
val pb: String,
val pb_value: Double
)
@Dao
interface PbDao {
@Query("SELECT * from pb_table ORDER BY pb ASC")
fun getListPbs(): LiveData<List<Pb>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(pb: Pb)
@Query("DELETE FROM pb_table")
suspend fun deleteAll()