Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Git
- notification setting
- ChromeCustomTab
- notification
- itemAnimator
- Android
- Plugins
- kdoc-generator
- 이미지 gps
- onReceivedSslError
- BottomSheetDialog
- Blinking
- prettyJson
- application
- notification bar
- App Startup
- shotcut
- navigation component
- circlecrop
- jsontokotlinclass
- datastore
- room
- onResume
- ActivityResultContracts
- requestPermission
- skipcollapsed
- webview
- 403 Error
- ExifInterface
- LOG
Archives
- Today
- Total
Debbi Story
android Room 데이터베이스 Replace 본문
728x90
보통 insert할때
@Insert(onConflict = OnConflictStrategy.REPLACE)
이렇게 충돌전략을 REPLACE로 많이 설정하게 된다.
기존 데이터에 업데이트를 하는줄 알았지만 그게 아니었다..
기존 데이터베이스에 있던걸 삭제하고 다시 insert가 되는것이었다.
그래서 이 테이블을 부모로하는 자식테이블에 onDelete = ForeignKey.CASCADE 이렇게 보통 CASCADE를 많이 사용해서
부모 데이터가 삭제되면 함께 사라지게 된다. 이것때문에 뭔가 오류가 있었던 기억이 나서 기록해본다 😂