Tina Tang's Blog

在哪裡跌倒了,就在哪裡躺下來

0%

在本程式碼研究室中,您要為 Inventory app 新增更多功能,並學習如何使用 Room 讀取、顯示、更新及刪除 SQLite database 中的 data。使用 RecyclerView 顯示 database 中的 data,並在 database 中的基礎資料(underlying data)發生變更時自動更新 data

學習目標

  • 如何讀取及顯示 SQLite database 中的 entities
  • 如何使用 Room library 更新和刪除 SQLite database 中的 entities
Read more »

使用 Room library 即可輕鬆在 Android app 中使用 database。Room 也稱為 ORM (Object Relational Mapping) library,顧名思義,就是將 relational database 中的 table 對應至可在 Kotlin 程式碼中使用的 objects。在本課程中,您只需要關注讀取 data。使用預先填入的 database,您就能載入公車抵達時間 table 中的 data,並在 RecyclerView 中呈現這些 data。

在課程中,您將瞭解使用 Room 的基礎知識,包括 database classDAO實體(entities)view models。此外,課程中也會介紹 ListAdapter class,讓您透過另一種方式在 RecyclerView 中呈現 data;以及 Flow,這是一種類似於 LiveData 的 Kotlin 語言功能,可使 UI 針對 database 變更做出 response

學習目標

  • 將 database table 以 Kotlin objects (實體(entities)) 表示。
  • 定義要用於在 app 中使用 Room 的 database class,並從檔案預先填入 database。
  • 定義 DAO class,並使用 SQL 查詢Kotlin 程式碼存取 database。
  • 定義 view models,以允許 UI 與 DAO 互動
  • 瞭解如何在 recycler view 中使用 ListAdapter
  • 瞭解 Kotlin Flow 的基本概念,以及學習如何實際運用,讓 UI 對基礎 data 的變更做出 response
Read more »

瞭解關聯資料庫(relational databases)的基本概念,並練習使用 Android Studio 中的資料庫檢查器(Database Inspector)執行 SQL 查詢(queries)

學習目標

  • 關聯資料庫(relational database)的結構:資料表(tables)資料欄(columns)資料列(rows)
  • 包含 WHEREORDER BYGROUP BYLIMIT 子句的 SELECT 陳述式
  • 如何使用 SQL insertupdatedelete 資料列(rows)
Read more »