I am creating an android application. It holds a downloading process from server. It’s running fine until the application runs and maintains the data without any crashes, but now I am stuck up with the problem as described below
When the application minimizes by pressing home button and after a long time, when I open the application all the data in the application are deleted. It gives me a “Null Pointer Exception”; even the ArrayList value are deleted and it gives a 0 sized arraylist.
I am opening the application after maximizing from the home screen through OnResume only, but it didn’t call itself.
I don’t know why this problem occurs. Can anyone please suggest me a solution and point me what am I doing wrong?
Yes, it’s true – as @paradx said – that the Garbage Collector throws away the data while the app is in background. Finally I found a solution based on @paradx suggestion, as data are stored in SQLite or savedInstanceState
Just pass some of static values through the
Then static hashmap are written in a file and retrieved for later use. Now the application does not crash for this problem.
I have posted this solution so that someone might use it.