关闭SqliteDatabase 的问题

220 阅读1分钟

根据链接中回答:

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.

大意 是 content provider 在宿主进程创建时即已创建,并和所在进程保持一样存活状态,database的连接会在进程被杀,回收进程资源时,作为kernal清理任务被关闭,所以不需要在进程活跃时关闭数据库链接。