Android : Static variable null on low memory -


i have application has static variables. these variables stored in independent class named datacontext. these variables initialized raw files @ application start (a method named datacontext.initconstant() called in oncreate() of myapplication extends application).

(edit : initconstant method use asynctask load data files).

when application comes background time or when application used memory, these static variables become null.

  1. how can prevented?

  2. if not should static variables?

    i have other data stored in static variables used across different activities, clear them or pass them null in onlowmemory() of myapplication.

  3. what best way keep data accessible between activities if these data big serialized in intent, database can't used (for whatever reason), , can't stored in files through serialization either?

most issue application being killed while in background, , recreated when come it. check out activity lifecycle documentation on when might occur single activity. need make sure move stored in memory more permanent storage @ correct point in time avoid losing information if app gets killed.

i'm not sure storing, sounds using shared preferences might work well. page on data storage explains number of different ways of more permanently storing data, including shared preferences.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -