tags:

views:

46

answers:

1

Hi Guys, I am working on an application where i am saving the state of an application in an ArrayList. Now, to save this state, i tried to use Serialization. But, somewhere in the user defined object, i am using Button, which is not letting me serialize the entire object.

I wanted to know, is there any other way of saving this array list between onPause and onResume?. I even tried onSaveInstanceState, but it doesnt have support for ArrayList.

Thanks, Chander

+1  A: 

But, somewhere in the user defined object, i am using Button

Never mix your models and views. Please redesign your "state" to be pure model data.

I wanted to know, is there any other way of saving this array list between onPause and onResume?

If it involves widgets like Button, then no.

Once you clean up your state, you can persist it to a database, or persist it to a JSON/XML file, or serialize it to a file, or whatever.

onSaveInstanceState() is solely for transient data, such as the contents of an EditText. Do not confuse this with the business data (model) for your application.

CommonsWare