我什么时候应该关闭DatabaseHelper? [英] When should I close the DatabaseHelper?

查看:77
本文介绍了我什么时候应该关闭DatabaseHelper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考链接,何时是关闭的好时机如果只有一个连接,该连接如何?我一直都在后台运行服务.什么时候是调用close()函数的好时机?有什么建议吗?

With reference to this link, when is a good time to close the connection if you only have one connection? I have a service running in the background at all times. When is a good time to call the close() function? Any suggestions?

推荐答案

您实际上不必调用close().例如,如果您实现内容提供程序,则没有机会调用close().我们被告知,由于SQLite的实现方式,不调用close()不会导致任何特定问题.

You do not actually have to call close(). For example, if you implement a content provider, there is no opportunity to call close(). We have been told that, due to the way SQLite is implemented, not calling close() will not cause any particular problem.

话虽这么说,您确实应该重新考虑让服务始终在后台运行".

That being said, you really should reconsider having "a service running in the background too all the time".

这篇关于我什么时候应该关闭DatabaseHelper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆