Android Room,如果没有匹配的行,查询将返回什么?

问题描述 投票:0回答:1
@Dao
interface  ExampleDao {
    @Query("SELECT * FROM example_table WEHRE id = :id")
    fun getExample(id: Int): LiveData<Example>
}

如果数据库中没有匹配的ID,上述查询返回什么?我猜它不能为null,因为返回类型不可为null。

如果返回类型可为空,查询是否返回null?像LiveData<Example>?LiveData<Example?>

android android-room android-architecture-components android-jetpack
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.