Android的时候,关闭DatabaseHelper?时候、Android、DatabaseHelper

2023-09-07 16:25:38 作者:不贪,不可不贪

参照此链接忙超时的SQLite在Android ,当是一个很好的时间来关闭连接,如果所有的u已经是1个连接?我在后台运行过的所有时间的服务,所以不知道哪里是好调用close()。谢谢!

With reference to this link Busy timeout for SQLite on Android, when is a good time to close the connection if all u have is 1 connection? I have a service running in the background too all the time, so was wondering where is good to call the close(). Thanks!

推荐答案

您实际上并不需要调用关闭()。例如,如果实现内容提供商,也没有机会打电话关闭()。我们被告知,由于SQLite的方式实现的,而不是调用关闭()不会引起任何特别的问题。

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".