Good way to cache data during Android application lifecycle?

后端 未结 3 525
忘了有多久
忘了有多久 2020-12-14 03:16

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 pa

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 03:45

    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.

    This blog post forgets to add that you have to set your CustomApplication class in the manifest, like:

    
    

    In my projects I stick to the singleton style via getInstance.

    More resources: this answer, Global Variables in Android Apps and this blog post.

提交回复
热议问题