-1

In my application, I have some data to display in the dashboard which are coming from the sqlite db. But when I put the app to the recent app and open the app from the recent app list on next day, those data don't display and showing the error message (that I set to show when there is no data in the sqlite).

To give a better idea about my issue, those are the basic steps.

  1. Install application
  2. Open Application
  3. Navigate through pages
  4. Keep the device
  5. Open Application on Next day
  6. Inspect the behaviour of Dashboard(No data showing)

I think android may auto kill the apps in the recent app.isn't it?.

How can I solve this issue?.

  • Implement the activity lifecycle correctly as described here: http://developer.android.com/reference/android/app/Activity.html You probably use static fields to store data, don't do that. – Henry May 03 '16 at 04:44

2 Answers2

0

If the data that you are storing are only with respect to your Activity and other classes, Android will clear off data as per priority for availing memory.

This is applicable to static variables also. Resolution for this will be storing the data using Parcelable interface.

  • Store data either using Parcelable or in Sqlite.
  • Retrieve the same when the Activity/Fragment is loaded again
  • Use plugin's available to generate these objects for ease of programming like android-parcelable-intellij-plugin-kotlin

For sample implementation use this reference StackOverflowLink

Community
  • 1
  • 1
Sreehari
  • 5,621
  • 2
  • 25
  • 59
0

I don't know how the app flow have been designed since there is no source code, but the following lifecycle will help you figure out the point where you are losing your data (I am assuming you are talking about the unsaved data).

Based on this, you might have to implement the onPause() and onResume() accordingly.

enter image description here

Supratim Haldar
  • 2,376
  • 3
  • 16
  • 26