Android Room:“没有此类桌子”的问题

时间:2019-01-22 18:57:12

标签: android android-room

我在android房间遇到了一个奇怪的问题。对我来说,这非常令人困惑,因此很难描述。 基本上,我有3种不同的活动,称为Dasbboard,Horse和Breed。 在仪表板上,您可以启动“马”或“品种”活动。根据我是否对“仪表板”活动中的任何一个表进行查询,打开另一个活动会崩溃,并提示不存在此类表。

这是DashboardActivity的一个代码段,在该代码段中,我对表的查询进行了注释。对model.getHorseCount()进行注释。如果我现在启动该应用程序并尝试打开Horse Activity,该应用程序将崩溃。同样适用于model.getBreed()行。

CLOSESPIDER_TIMEOUT = 30

跟随堆栈跟踪:

    @Override
    protected void onStart() {
        super.onStart();

        DashboardViewModel model = (DashboardViewModel) ViewModelProviders.of(this).get(DashboardViewModel.class);

        TextView tvHorses = findViewById(R.id.textViewHorsesCount);
        TextView tvBreeds = findViewById(R.id.textViewClientsCount);

//        model.getHorseCount().observe( this, count -> tvHorses.setText(String.valueOf(count)));
        model.getBreedCount().observe( this, count -> tvBreeds.setText(String.valueOf(count)));

    }

我不知道在这里放置很多代码片段有多大意义。如果有帮助,我肯定会的。但是我认为最好是从github上获取我的代码并看看自己。

您可以在这里获取它:https://github.com/Nexotap/Roomtester

感谢您的帮助。

0 个答案:

没有答案
相关问题