0Pricing
Jetpack Compose Academy · Ders

Varlıklar, DAO'lar ve Veritabanı

Yerel şemanızı Room ile tanımlayın.

Varlıklar, DAO'lar ve Veritabanı, CoddyKit'te ücretsiz bir Jetpack Compose Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Jetpack Compose Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Room Is Your Local SQLite

Room is a friendly layer over SQLite. It lets you save data on the device with plain Kotlin classes instead of raw SQL strings. 💾

Three Core Pieces

Room has exactly three building blocks: an Entity for the table, a DAO for the queries, and a Database that ties them together.

An Entity Is a Table

Annotate a data class with @Entity and Room turns it into a database table, one column per property.

@Entity
data class Note(val text: String)

Every Row Needs a Key

Mark one field as the @PrimaryKey so each row is uniquely identified. Use autoGenerate to let Room assign ids for you.

@PrimaryKey(autoGenerate = true)
val id: Int = 0

The DAO Holds Your Queries

A @Dao interface declares the operations you want. You write the intent, and Room generates the implementation.

@Dao
interface NoteDao {
    // queries go here
}

Insert With One Annotation

Add a function and tag it with @Insert. Room writes the SQL that saves your entity to the table.

@Insert
suspend fun insert(note: Note)

Read With @Query

Use @Query with real SQL to fetch rows. Room checks the query against your schema at compile time.

@Query("SELECT * FROM Note")
suspend fun getAll(): List<Note>

Update and Delete Too

The same pattern covers writes: @Update and @Delete change existing rows by matching their primary key.

@Delete
suspend fun delete(note: Note)

The Database Class

Declare an abstract class with @Database, list your entities, and expose each DAO. This is the single entry point.

@Database(entities = [Note::class], version = 1)
abstract class AppDb : RoomDatabase() {
    abstract fun noteDao(): NoteDao
}

Build the Database Once

Create the instance with Room.databaseBuilder. Building it is expensive, so do it a single time and reuse it.

Room.databaseBuilder(context, AppDb::class.java, "app.db").build()

Suspend Keeps the UI Smooth

Disk access is slow, so mark DAO functions suspend. Room then runs them off the main thread and never freezes your screen.

Quick Check

Which annotation marks a Kotlin class as a Room database table?

Recap: The Three Pillars

You defined an Entity table, a DAO of suspend queries, and a Database that wires them up. Next you will make those reads reactive.

Sıkça Sorulan Sorular

“Varlıklar, DAO'lar ve Veritabanı” dersi ücretsiz mi?

Evet — “Varlıklar, DAO'lar ve Veritabanı” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Jetpack Compose Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

“Varlıklar, DAO'lar ve Veritabanı” dersinde ne öğreneceğim?

Yerel şemanızı Room ile tanımlayın. Jetpack Compose Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Jetpack Compose Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Jetpack Compose Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Varlıklar, DAO'lar ve Veritabanı” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Jetpack Compose Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Jetpack Compose Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Varlıklar, DAO'lar ve Veritabanı
  2. Flow Döndüren Tepkisel Sorgular
  3. Repository Deseni
  4. Çevrimdışı Öncelikli Önbellekleme Stratejisi
← Jetpack Compose Academy Sayfasına Dön