ViewModel中的DAO返回null

时间:2020-02-17 01:50:42

标签: android android-room android-livedata

// In my ViewModel that is setup to use Room I use the following in a function
// The dao returns a LiveData object and I call getValue() to get the value
{
    List<Item> items = (List<Item>) dao.loadAllByParentId(id).getValue(); // This is null
    deleteItems(items);
}

然后,该应用程序将NullPointerException抛出到我跟踪到此代码段的其他位置。 我不太了解Android,所以我知道对于某些人来说这似乎微不足道,但是请您帮忙,我将不胜感激。

0 个答案:

没有答案