Room Database Setup

This commit is contained in:
202310715297 RAIHAN ARIQ MUZAKKI 2025-11-13 10:29:10 +07:00
parent 7190b1574d
commit 793600dd5a

View File

@ -1,31 +0,0 @@
package com.example.notebook.data
import android.content.Context
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
/**
* Helper untuk test database
* Panggil fungsi ini dari MainActivity untuk test
*/
class DatabaseTest(private val context: Context) {
private val database = AppDatabase.getDatabase(context)
private val dao = database.notebookDao()
fun testInsertNotebook() {
CoroutineScope(Dispatchers.IO).launch {
val testNotebook = NotebookEntity(
title = "Notebook Test",
description = "Ini adalah test database",
createdAt = System.currentTimeMillis(),
updatedAt = System.currentTimeMillis(),
sourceCount = 0
)
val id = dao.insertNotebook(testNotebook)
println("✅ Database Test: Notebook berhasil disimpan dengan ID: $id")
}
}
}