美文网首页
三级联动,对数据库的操控出错

三级联动,对数据库的操控出错

作者: 菜鸟考官 | 来源:发表于2017-08-10 10:40 被阅读0次
                                                                    Process: com.yuyigufen.ecanal, PID: 8065
                                                                    java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/com.yuyigufen.ecanal/files/city.db
                                                                        at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
                                                                        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1312)
                                                                        at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
                                                                        at com.qit.citywheelview.wheelview.util.CityDatabaseUtil.getLeaders(CityDatabaseUtil.java:80)
                                                                        at com.qit.citywheelview.CityWheelDialog$3.onChanged(CityWheelDialog.java:137)
                                                                        at com.qit.citywheelview.wheelview.WheelView.notifyChangingListeners(WheelView.java:295)
                                                                        at com.qit.citywheelview.wheelview.WheelView.setCurrentItem(WheelView.java:409)
                                                                        at com.qit.citywheelview.wheelview.WheelView.doScroll(WheelView.java:796)
                                                                        at com.qit.citywheelview.wheelview.WheelView.access$100(WheelView.java:48)
                                                                        at com.qit.citywheelview.wheelview.WheelView$1.onScroll(WheelView.java:167)
                                                                        at com.qit.citywheelview.wheelview.WheelScroller$2.handleMessage(WheelScroller.java:206)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5441)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
    

    使用三级联动的时候,调用本地数据库,当窗口关闭的时候,把连接数据库也关闭了,再打开的时候就导致这个错误。

     public void closeDb() {
        //关闭数据库连接
        sqLiteDatabase.close();
    }
    

    解决方法:关闭数据库的操作放进应用程序退出操作中

    相关文章

      网友评论

          本文标题:三级联动,对数据库的操控出错

          本文链接:https://www.haomeiwen.com/subject/uxzcrxtx.html