日志堆栈信息:
1. Caused by: net.sqlcipher.database.SQLiteFullException: database or disk is full: COMMIT; 2. at net.sqlcipher.database.SQLiteDatabase.native_execSQL(Native Method) 3. at net.sqlcipher.database.SQLiteDatabase.execSQL(SourceFile:4) 4. at net.sqlcipher.database.SQLiteDatabase.endTransaction(SourceFile:19) 5. at com.commonsware.cwac.saferoom.b.endTransaction(SourceFile:1) 6. at androidx.room.RoomDatabase.endTransaction(SourceFile:1) 7. at com.model.class.b.r.insert(SourceFile:5) 8. at com.model.class.b.p$a.a(SourceFile:1) 9. at com.model.class.b.p$a.call(SourceFile:1) 10. at io.reactivex.internal.operators.observable.ObservableFromCallable.subscribeActual(SourceFile:4) 11. at j.a.o.subscribe(SourceFile:14) 12. at io.reactivex.internal.operators.observable.ObservableSubscribeOn$b.run(SourceFile:1) 13. at j.a.w$a.run(SourceFile:2) 14. at j.a.h0.g.m.run(SourceFile:2) 15. at j.a.h0.g.m.call(SourceFile:1) 16. at java.util.concurrent.FutureTask.run(FutureTask.java:237) 17. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154) 18. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 19. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 20. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
【根本原因】数据库或磁盘已满。数据库插入操作没有处理异常,导致报错
【解决方案】对数据库插入操作进行异常处理
可从log7、8、9中 model.class 定位报错相关类,或从听云中【异常溯源中定位】具体类
在插入代码块中增加代码:
.doOnError(e -> Log.e("DeviceExpandDao", "insert: ", e))
添加后完整代码:
public void insert(List<DevExpandInfoBean> infoBeans) { if (ValidUtils.isListEmpty(infoBeans)) { return; } Observable .fromCallable(() -> { DatabaseManager.getInstance().getAppDatabase() .deviceExpandDao().insert(new CopyOnWriteArrayList<>(infoBeans)); return true; }) .doOnError(e -> Log.e("DeviceExpandDao", "insert: ", e)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(); }