gpt4 book ai didi

android - 适用于 Android 的 Ormlite,值得发布帮助程序吗?

转载 作者:太空狗 更新时间:2023-10-29 12:45:21 25 4
gpt4 key购买 nike

按照建议,我使用单例来获取助手(我保证它首先是在我的应用程序的 onCreate() 上使用应用程序上下文创建的)。

然后从不同的 [Intent] 服务使用这个助手,但我对发布感到困惑:我已经读过这个 related question ,但是关于 releaseHelper() 的 ormlite 文档似乎自相矛盾:

WARNING: This should be called in an onDestroy() type of method when your application or service is terminating or if your code is no longer going to use the helper or derived DAOs in any way. Don't call this method if you expect to call {@link #getHelper(Context)} again before the application terminates.

上面警告的第二部分告诉我们不要调用 releaseHelper() 如果我们期望在应用程序终止之前再次调用 getHelper() ,如果另一个服务在应用程序进程终止!

此外,根据this post ,不释放助手在 Android 上听起来很安全。

我是不是误会了?

最佳答案

我必须同意这种混淆。

http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_4.html#Use-With-Android说明要在每个 Activity/Fragment 的 onDestroy() 上调用 OpenHelperManager.releaseHelper(),但 releaseHelper() 上的警告注释清楚地告诉您仅在 Application 终止时使用它。

也许 releaseHelper() 注释中的警告不再相关?和 Kevin Galligan's warning post也因为他离开项目后发生变化而不再相关?

关于android - 适用于 Android 的 Ormlite,值得发布帮助程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18889321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com