Caching object in application context

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Mar 19, 2015 7:25:46 AM via Website

We have a data intensive android application. The users have to enter data on around 25-28 tabs(fragments) on one Activity. The user keeps working on the each tab entering data while the application saves the data on a scheduled interval (every 90 seconds) to the SQLLite database. The auto save feature that we have built kicks off which saves the data the user enters in each tab to the sqllite database.

In order to have access to the data throughout the application, we store the data in an object within the Application Context. We have a class that extends the Application class and the data the user enters on the tabs will be set to the object in the Cache and the Save Operation pushes this data back to the SqlLite. The tablet is supposed to work on offline mode.

However, sometimes when we access cached object in the Save Operation, even while the user is working on entering data, the object becomes null and returns as null to the Save Operation which skips the save. Therefore the user loses about 90 seconds worth of data entered which is causing lot of annoyance on the field. They don’t see any application crash. We just know that the save is not happening due to null Object.

This happens only in production for about 9-10 random users everyday out of 1000 users about 3 to 5 times. This started happening with the same code base but when we started giving out Samsung Galaxy Tab4s to the users. Before the users were on Tab1 and Tab2s. There are still some users on Tab1 and Tab2s and they don’t encounter this situation.

The object we are saving in application cache is around 250-350kb.

We are trying to see how to prevent the object in the application context from becoming null. Has anyone encountered this?

Should we move this object to an Activity?


— modified on Mar 19, 2015 7:28:41 AM