└ Android Architecture Component/ROOM(3)
-
[AAC/Room] Exception - Cannot access database on the main thread since it may potentially lock the UI for a long period of time. 해결 방법
1. Exception 확인 java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time. 2. 발생 원인 Room 사용 시 쿼리 호출을 MainThread에서 실행했을 경우 발생 3. 해결 방법 allowMainThreadQueries() 메서드를 사용하면 간단하게 해결할 수 있지만 메인 스레드에서 많은 양의 쿼리문을 실행하다 보면 ui가 오랜 기간 동작하지 않을 수 있으므로 사용하면 안 되는 방법이다! 이외에 AsyncTask, RxJava, Coroutine, JavaThread를 사용하여 해결할 수 있습니다 오늘 ..
2020.06.10 -
[AAC/Room] 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.
Exception 확인 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. 해결 방법 1. database version up @Database(entities = [MyBook::class], version = 1, exportSchema = false) 2. fallbackToDestructiveMigration() method 추가 해주기
2020.06.10 -
[ACC/Room] illegalstateexception pre-packaged database has an invalid schema 해결 방안
illegalstateexception : pre-packaged database has an invalid schema 발생이유 : 데이터베이스 스키마를 수정하였지만 atabase Annotation의 Version값을 올려주지 않았을 경우 (Room will throw an IllegalStateException if you don’t provide a Migration.) 간단 해결 방안 : .allbackToDestructiveMigration() 옵션을 줄경우 따로 Migration정의를 해주지 않아도 되지만 이전에 생성한 데이터베이스를 삭제한 후 새로운 데이터베이스를 생성한다 ... INSTANCE = Room.databaseBuilder( context, MyDB::class.java, "M..
2020.05.28