Common patterns when building Room DB

Dmitry Klokov·2021년 1월 22일
0

ANDROID-KOTLIN-ADVANCED

목록 보기
1/2
post-thumbnail
post-custom-banner

Pattern 1


Inside abstract class, private var instance: AppDatabase? with @Volatile keyword.

Pattern 2


Outside abstract class, private lateinit var INSTANCE: TitleDatabase.

Note: getDatabase() checks whether INSTANCE has been initialized during runtime using property reflection(::INSTANCE.isInitialized).

profile
Power Weekend
post-custom-banner

0개의 댓글