SQLiteDatabase close() function causing NullPointerException when multiple threads

后端 未结 4 1332
小鲜肉
小鲜肉 2020-11-30 13:00

I discovered in my project that the close() function in the SQLiteDatabase implementation on Android throws a NullPointerException when running multiple threads that open th

4条回答
  •  有刺的猬
    2020-11-30 13:31

    You don't need to bother. See this discussion which includes confirmation that closing the database is done by the system as needed if/when the process is killed off.

    The relevant quote, from a Google employee, is:

    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.

提交回复
热议问题