When to close db connection on android? Every time after your operation finished or after your app exit

后端 未结 4 679
清歌不尽
清歌不尽 2020-12-01 03:56

I have an android application that access local sqlite3 db frequently, for performance consideration so i always keep the connection open. But one of my friends recommended

4条回答
  •  生来不讨喜
    2020-12-01 04:06

    As an addition, opening & closing a connection so frequently might possibly cause you to experience notorious SQLite exceptions, if you access db from multiple threads.

    See, if you access db from multiple threads even over a single connection and since those operation are not atomic, then you may try to update db which was closed just before by another thread.

提交回复
热议问题