안드로이드/공부

안드로이드 Room,LiveData,ViewModel 예제(Codelaps)-2

바코더 2020. 5. 1. 09:42

2. App overview

https://codelabs.developers.google.com/codelabs/android-training-livedata-viewmodel/#1

 

Android fundamentals 10.1 Part A: Room, LiveData, and ViewModel

The data access object, or Dao, is an annotated class where you specify SQL queries and associate them with method calls. The compiler checks the SQL for errors, then generates queries from the annotations. For common queries, the libraries provide conveni

codelabs.developers.google.com

 샘플앱은 Android Architecture Component를 사용하는 앱을 만들어 볼건데, 이 앱은 RoomWordsSample 로 단어 리스트를 Room database에 가지고 있다가 RecyclerView를 이용해서 그 리스트들을 보여주는 앱입니다. 이 앱은 매우 기본적이지만 기반이 되는 템플릿으로 사용하기에 충분합니다. 이 앱은 다음과 같은 순서로 진행 됩니다.

 

  • 데이터베이스에서 작업을 수행하여 단어를 가져오고 저장하고 데이터베이스에 몇 개의 단어를 미리 입력합니다.
  • 메인 액티비티의 RecyclerView에 모든 단어를 표시합니다
  • 세컨드 액티비티를 열고 유저가 +Fab button 을 클릭하고 문자를 입력하면 자동적으로 데이터 베이스와 리스트에 업데이트 됩니다.

 

클래스 다이어그램은 다음과 같습니다.