我有一个应用程序,它使用 SQLite 数据库,我正在尝试将 Android SQLite 替换为 Android Room API。我已经创建了 DAO 类、实体类和数据库,但当在异步任务中执行数据库查询时,我会收到以下错误信息:
``` Caused by: java.lang.IllegalStateException: A migration from 3 to 1 is necessary. Please provide a Migration in the builder or call fallbackToDestructiveMigration in the builder in which case Room will re-create all of the tables. at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:82) at android.arch.persistence.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:94) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:128) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:93) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54) at android.arch.persistence.room.RoomDatabase.query(RoomDatabase.java:193) at com.rasfi.ai.domain.room.RecordingDAO_Impl.getAll(RecordingDAO_Impl.java:112) at com.rasfi.ai.ui.acivities.HomeActivity$1.doInBackground(HomeActivity.java:106) at com.rasfi.ai.ui.acivities.HomeActivity$1.doInBackground(HomeActivity.java:102) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:760) 01-10 08:13:37.648 30267-30339/com.rasfi.ai E/UncaughtException: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:318) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) ```
我不明白我漏掉了什么,需要帮助。
``` Caused by: java.lang.IllegalStateException: A migration from 3 to 1 is necessary. Please provide a Migration in the builder or call fallbackToDestructiveMigration in the builder in which case Room will re-create all of the tables. at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:82) at android.arch.persistence.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:94) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:128) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:93) at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54) at android.arch.persistence.room.RoomDatabase.query(RoomDatabase.java:193) at com.rasfi.ai.domain.room.RecordingDAO_Impl.getAll(RecordingDAO_Impl.java:112) at com.rasfi.ai.ui.acivities.HomeActivity$1.doInBackground(HomeActivity.java:106) at com.rasfi.ai.ui.acivities.HomeActivity$1.doInBackground(HomeActivity.java:102) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:760) 01-10 08:13:37.648 30267-30339/com.rasfi.ai E/UncaughtException: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:318) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) ```
我不明白我漏掉了什么,需要帮助。