On example we have an app that tracks Taxi drivers, a taxi driver log in into application and pick an order to drive for given customer.
In this case we have an Order class that represents a lot of data, it's very important to have access to this object from anywhere while still being able to modify it.
From now we can:
- pass it by putting extra data to an intent, but it's not something that makes code readable, in some cases it won't be a solution
- deserialize the object into json and store it into cache, we still need to constantly update this value which is a headache when more complex objects are in game, one mistake and god knows when the mismatch happens
- store it into class that extends Application, this is approach I am testing right now, but I am having doubts about this as when app crashes / android will release app resources randomly, I am in need to restore given object state using black magic with cache anyway
This is a problem that I believe is shared across many applications, like Spotify's current playing track, etc.
Are there other approaches?