I am currently facing a problem with persisting object state in an android app.
I have some kind of multi level master-detail flow.
For example, I have a list of Client
s. Each Client
has multiple Order
s and each Order
has multiple articles.
Until now I did the following:
- When you click a
Client
in theMasterActivity
I write theClient
into theBundle
and open theDetailActivity
. - In the
DetailActivity
I read theClient
from theBundle
and display it.
This worked more or less fine most times, however it now happens, that an object is too big to be serialized (for example a Client
with a lot of Order
s).
Therefore I wanted to serialize only the ID of the Client
and load it from the database inside the DetailActivity
. Usually this approach works fine but I have one situation where it does not work:
The Article
s are only saved, when you save the Order
(their Master
). So if you create a new Article
for an Order
and you don't save the Order
, the Article
isn't saved too.
That means, that I always need to have the full object, reloading it
from the database inside the DetailActivity
means, that I loose all the unsaved changes. However, persisting it, using the Bundle
s could exceed the limit (500kB to 1MB).
So my question is, what is the preferred way to persist such data?