保持我的问题总之,我已经创建了一个应用程序有3个活动,其中A - 类名单,B - 产品清单,C - 单个项目。在B和C的数据显示,从网上XML解析。但是,如果我去到A - > B1 - > C,然后再返回到A,然后回到B1,我想有它的数据缓存的地方,所以我就不必再次请求XML
keeping my question short, I have created an application with 3 activities, where A - list of categories, B - list of items, C - single item. Data displayed in B and C is parsed from online XML. But, if I go through A -> B1 -> C, then back to A and then back to B1, I would like to have its data cached somewhere so I wouldn't have to request the XML again.
我是新来的Android和Java编程,我GOOGLE了很多,但仍无法找到(或根本就没有一个想法去哪里找)的方式做我想做的。
I'm new to Android and Java programming, I've googled a lot and still can't find (or simply do not have an idea where to look) a way to do what I want.
会存储所有收到的主要活动数据(包含HashMap?ContentProviders?),然后传递给B和C(如果他们那是以前同样的要求)是一个好主意?
Would storing all received data in main activity A (HashMaps? ContentProviders?) and then passing to B and C (if they get same request that was before) be a good idea?
一个简单快速的方法来缓存信息,或者跟踪应用程序的状态,就是在描述延长的应用程序的< A HREF =http://blog.tomgibara.com/post/126377651/global-application-state-in-android>这篇博客。
A simple and fast way to cache information or to keep track of the application state, is to extend the Application as described in this blog post.
本博客文章忘记补充一点,你必须设置你的 CustomApplication 的清单中类,如:
This blog post forgets to add that you have to set your CustomApplication class in the manifest, like:
<application [...] android:name="CustomApplication">
在我的项目中,我首先通过getInstance坚持单身风格。
In my projects I stick to the singleton style via getInstance.
更多资源:这个答案,的