0

I am having an abstract class having all static objects and function to store some globel data of the application during the execution session.

All data reset to null once I relaunch the application in ICS and above version with Systems's setting ALWAYS_FINISH_ACTIVITIES is set as true.

Whats the better way to mainitan data on application relaunch?

Regards,

Android IT

Editing my question: I know that Sharepreference can be a better option but I dont want to store data for multiple sessions of the application and data I am storing is huge. Regards, Android IT

Android_IT
  • 396
  • 2
  • 5
  • 24

6 Answers6

1

Each Android app is running in a dependent process. When an app become background and system need memory, the app's process may be killed by system. In this situation, when app relaunch, static objects will lost.

I think use SharedPreference to maintain data is a better way.

Ponyets
  • 336
  • 1
  • 9
0

You can store data using SharedPreferences http://developer.android.com/reference/android/content/SharedPreferences.html

Sameer
  • 4,379
  • 1
  • 23
  • 23
0

Store the data on the local storage would seem appropriate: http://developer.android.com/training/basics/data-storage/index.html

goncaloGomes
  • 163
  • 11
0

You can store the data local using a XML file. You can read the XML File on startup with a DOM Reader

http://www.ibm.com/developerworks/library/x-android/

If you have lots of data you can use a SQLite Database

http://developer.android.com/training/basics/data-storage/databases.html

ObAt
  • 2,337
  • 3
  • 24
  • 44
0

If there are not too much data you can keep them in SharedPreferences

You access them with PreferenceManager.getDefaultSharedPreferences()

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
0

Once application exit or destroy that will remove all data . if you want to access after relaunch you should save your data as per your requirement . like local or web. its deepen you. right now you can store data in preference so it will useful after relaunch the application. I think this is better for you : How to use SharedPreferences in Android to store, fetch and edit values

Community
  • 1
  • 1
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85