如何通过活动之间数据库对象(Android版) [英] How to pass database objects between activities (Android)
本文介绍了如何通过活动之间数据库对象(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法通过活动之间数据库对象。我已经尝试通过以下方式这样做。
- 实现接口。
- 使用功能。
解决方案
我猜你正在寻找一个Singleton。也许这将帮助您:
如果您正在使用的 SQLiteOpenHelper 我强烈建议你阅读本:
我觉得你应该罚款是办法#1 ,它使用与抽象工厂模式是独生子。阅读文章的内容非常丰富。
更多关于该主题和优点缺点ñ这里
Is there any way to pass database object between activities. I have already tried the following ways for doing this.
- Implementing interface.
- Using functions.
解决方案
I guess you are looking for a Singleton. Maybe this will help you:
If you are using a SQLiteOpenHelper I HIGHLY recommend you to read this:
I think you should be fine with Approach #1 which uses a singleton with the abstract factory pattern. Read the article its very informative. More on the topic and Pros n cons are here
这篇关于如何通过活动之间数据库对象(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文