Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

android - Since I created my second table I get: Room cannot verify the data integrity

I already followed approaches from Room cannot verify the data integrity . I tried rebuilding project and deleting my app from emulator but I'm still stuck with this error. Since I created my second table RezeptDetails, my app crashes.

This is what my database files look like:

@Dao
interface RezeptDetailsDao {
    @Query("SELECT * FROM rezept_details")
    fun getAll(): List<RezeptDetails>
}

@Entity(
    foreignKeys = [
        ForeignKey(
            entity = Rezept::class,
            parentColumns = ["uid"],
            childColumns = ["rezept_id"],
            onDelete = ForeignKey.CASCADE,
            onUpdate = ForeignKey.CASCADE
        )
    ],
    tableName = "rezept_details"
)
data class RezeptDetails(
    @PrimaryKey(autoGenerate = true) val uid: Int,
    @ColumnInfo(name = "rezept_id", index = true) val rezeptId: Int,
    @ColumnInfo(name = "zutat") val zutat: String,
    @ColumnInfo(name = "menge") val menge:Int,
    @ColumnInfo(name = "einheit") val einheit:String
)

@Entity(tableName = "rezepte")
data class Rezept(

    @PrimaryKey(autoGenerate = true) val uid: Int,
    @ColumnInfo(name = "rezept_name") val rezeptname: String?,
    @ColumnInfo(name = "image_path") val imagePath: String?
)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...