Android SQLite closed exception

后端 未结 2 730
别那么骄傲
别那么骄傲 2020-12-03 06:11

I have no solid background of synchronization. I think this issue will be fixed when I use synchronized method. But can anyone help me to fix this issue? Code is be

相关标签:
2条回答
  • 2020-12-03 06:22

    You should not close the DB since it will be used again in the next call. So try to remove the

    db.close();
    

    from your code.

    0 讨论(0)
  • 2020-12-03 06:35

    According to Dianne Hackborn (Android framework engineer) there is no need to close the database in a content provider

    A content provider is created when its hosting process is created, and remains around for as long as the process does, so there is no need to close the database it will get closed as part of the kernel cleaning up the process's resources when the process is killed.

    So there is no need to close the database . it will automatically close when it is not needed.

    0 讨论(0)
提交回复
热议问题