Room2 [Android] Room 사용법과 RecyclerView를 활용한 예제 이번 예제는 안드로이드의 가상 데이터베이스인 room을 활용해 데이터를 저장하고, 그것을 recyclerview에 보이게 하는 예제를 해보겠다. room 을 사용하기 위해서는 먼저 gradle에 추가를 해줘야 한다. build.gradle(app) plugins { id 'kotlin-kapt' ... } android { ... } dependencies { implementation "androidx.room:room-runtime:2.4.2" kapt "androidx.room:room-compiler:2.4.2" } 추가를 하고 나서, 데이터베이스에 들어갈 데이터들을 만들줘야 한다. 1. 데이터베이스 개체 클래스 생성 @Entity(tableName = "chat_table") class Chat.. 2022. 4. 12. [Android] Room에서 데이터 무결성을 확인할 수 없습니다. 필자는 room을 이용한 예제를 만들다가 한 오류를 만났다. 오류 코드 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. 번역을 하면 Room에서 데이터 무결성을 확인할 수 없습니다. 스키마를 변경했지만 버전 번호를 업데이트하는 것을 잊은 것 같습니다. 버전 번호를 늘리면 간단히 해결할 수 있습니다. 라고 해서 버전 번호를 바꿔보았다. 기존 코드 @Database(entities = [UserE.. 2022. 4. 11. 이전 1 다음 728x90 반응형