Aiden
11/26/2019, 10:23 AMimplements
word.
1. Why the ProductDatabase can use abstract
to initialize interface
class? abstract fun productDao(): ProductDao
2. What does the line of code means and trying to do?
@Database(entities = [Product::class], version = 1)
abstract class ProductDatabase : RoomDatabase() {
abstract fun productDao(): ProductDao
}
@Dao
interface ProductDao {
@Insert
fun insert(product: Product)
@Update
fun update(product: Product)
@Delete
fun delete(product: Product)
@Query("SELECT * FROM products")
fun all(): LiveData<Array<Product>>
@Query("SELECT * FROM products WHERE id = :id")
fun get(id: Int): Product
}
bezrukov
11/26/2019, 10:41 AMProductDao_Impl
that implements ProductDao
and ProductDatabase_Impl
that implements ProductDatabase
for you.bezrukov
11/26/2019, 10:43 AMProductDatabase_Impl
implements this fun
2. In impl it simply creates ProductDao_Impl(db)
bezrukov
11/26/2019, 10:45 AMAyden
11/26/2019, 12:12 PM