简体   繁体   中英

Find when application data clear from context?

在我的应用程序中,我正在应用程序上下文中存储一些数据。当我打开4到5个其他应用程序时,我的应用程序数据从上下文中是清除的。有什么办法可以找到我的应用程序数据何时从上下文中清除。

You application context is available to you only when you are using your application, if you leave it will goes for garbage collection.

Background process limit on android-

If you own a device that is lacking in processing power and memory, you can use this feature to limit the number of background process that can run between 0 and 4 processes.

To change your device process limit-

  1. Go to Android device 'Settings'
  2. Go to 'Developer options'
  3. Enable Developer option by sliding to the right.
  4. You get a warning pop-up message. Click on OK.
  5. Scroll down, under 'Apps' tap on 'Limit background processes'.
  6. Another pop-up appears and this is where you can limit background processes. 'Standard limit' will be selected by default. You have an option to select one of the six options.

From android documentation -

By default, every application runs in its own Linux process. Android starts the process when any of the application's components need to be executed, then shuts down the process when it's no longer needed or when the system must recover memory for other applications.

You need to use SharedPref to shave your application data.

public static final String PREFS_NAME = "MyPrefsFile";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM