Frontend/Kotlin (Andriod)
[Andriod/Kotlin] Room cannot verify the data integrity | RoomDB
chaerlo127
2022. 11. 24. 02:13
728x90
RoomDB๋ฅผ ์์ฑํ์ฌ ๊ณผ์ ๋ฅผ ์งํํ๋ ์ค์ Room cannot verify the data integrity ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
attirbute์ type์ ๋ณํํ์ฌ ๋ค์ ์คํ์์ผฐ๋๋ฐ,
RoomDB์ ์ด๋ฏธ ์์ฑ ๋์ด ์๋ attirbute์ ์ถฉ๋์ด ๋ฐ์ํ์ฌ ์๋ฌ๊ฐ ๋ฐ์ํ ๊ฒ์ด๋ค.
๋ฐ๋ผ์ ์๋ก DB๋ฅผ ์์ฑํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์๋ค.
RoomDB๋ฅผ ์ด๊ธฐํํ๋ ๋ฐฉ๋ฒ์ ์ฐพ์์ผ ํ ๊ฒ ๊ฐ๋ค.
@Synchronized
fun getInstance(context: Context) : AppDatabase ? {
if(appDatabase == null){
synchronized(AppDatabase::class.java){
appDatabase = Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java,
"week_8" // ์ด๋ฆ ๋ณ๊ฒฝ
).allowMainThreadQueries().build()
}
}
return appDatabase
}
728x90