Android Room Database with Safe Args
사용 버전: Android Studio 4.0.1
사용 언어: Kotlin 1.4.0
Room Database를 Safe Args를 통해서 다음 Fragment로 전달할 수 있습니다.
Safe Args가 필요합니다.
사용 언어: Kotlin 1.4.0
안드로이드 Room Database with Safe Args를 해보겠습니다.
Room Database를 Safe Args를 통해서 다음 Fragment로 전달할 수 있습니다.
Safe Args가 필요합니다.
Room Database가 필요합니다.
Room Database를 Safe Args를 통해서 다음 Fragment로 전달하겠습니다.
여기서 필요한 것은 Parcelable입니다.

위와 같은 Room Database table이 있습니다.
해당 테이블을 Safe Args로 전달할 겁니다.
우선 @Parcelize를 추가합니다. 그리고 Parcelable을 상속합니다.

navigation으로 와서 목적지의 Arguments에 + 버튼을 누릅니다.

Custom Parcelable을 누릅니다.

아까 우리가 Parcelable로 만든 Class가 보입니다.

선택합니다.
이름을 정하고 Add를 누릅니다.

Rebuild를 해줍니다.
Fragment로 와서 args를 받습니다.

결과입니다.

끝.
카테고리: Android
댓글
댓글 쓰기
궁금한 점은 댓글 달아주세요.
Comment if you have any questions.