开发者

Android: Saving ArrayList of User Defined Objects between onPause and onResume

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 Seria开发者_Python百科lization. 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜