如何在Android中共享多个活动之间的相同的数据? [英] How to share same data between multiple activities in android?
本文介绍了如何在Android中共享多个活动之间的相同的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个登录会话ID,多个活动需要使用。如何共享多种活动之间的共同的数据? presently,我传递数据的意图,但它不能正常工作。对于一些活动,我通过一些其它的数据,并且公共数据丢失。
I have a login session ID which multiple activities need to use. How do I share this common data between multiple activities? Presently, I'm passing the data in the Intent but it is not working properly. For some activities, I pass some other data, and the common data is lost.
推荐答案
要做到这一点是扩大的一种方式应用程序
,然后调用 getApplication
你们的活动。 本网站有一些例子。
One way to do it is to extend Application
, and then call getApplication
in your activities. This site has some examples.
这篇关于如何在Android中共享多个活动之间的相同的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文