У меня странная проблема с комнатой Android. Для меня это довольно запутанно, поэтому трудно описать.
В основном у меня есть 3 различных вида деятельности, которые называются Dasbboard, Horse и Breed.
На панели инструментов можно запустить либо лошадь, либо породу. В зависимости от того, выполнил ли я запрос к одной из таблиц в действии Dashboard, открытие другого действия завершается с сообщением об отсутствии такой таблицы.
Вот фрагмент из DashboardActivity, где я прокомментировал запрос к таблице. model.getHorseCount () прокомментирован. И если я сейчас запускаю приложение и пытаюсь открыть Horse Activity, приложение вылетает. То же самое относится и к строке model.getBreed ().
@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)));
}
По следу стека:
2019-01-22 19:40:51.500 31771-31789/ch.labrat.roomtester E/SQLiteLog: (1) no such table: horse
2019-01-22 19:40:51.501 31771-31789/ch.labrat.roomtester E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_0
Process: ch.labrat.roomtester, PID: 31771
android.database.sqlite.SQLiteException: no such table: horse (code 1 SQLITE_ERROR): , while compiling: SELECT * from horse ORDER BY name ASC
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:514)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1408)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1383)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.query(FrameworkSQLiteDatabase.java:161)
at androidx.room.RoomDatabase.query(RoomDatabase.java:238)
at ch.labrat.roomtester.features.horse.HorseDao_Impl$5.compute(HorseDao_Impl.java:288)
at ch.labrat.roomtester.features.horse.HorseDao_Impl$5.compute(HorseDao_Impl.java:274)
at androidx.lifecycle.ComputableLiveData$2.run(ComputableLiveData.java:101)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Я не знаю, какой смысл вкладывать сюда много фрагментов кода. Если это поможет, я уверен, что подойдет. Но я думаю, что лучше всего получить мой код из github и увидеть себя.
Вы можете получить его здесь: https://github.com/Nexotap/Roomtester
Я ценю любую помощь.