开发者

How to save an array of objects

开发者 https://www.devze.com 2023-02-28 10:15 出处:网络
So, I\'m making a trivia game and so I created a custom array of questions. I have an xml file in the raw folder that holds all the questions, and parses everything into my array. I want to have the a

So, I'm making a trivia game and so I created a custom array of questions. I have an xml file in the raw folder that holds all the questions, and parses everything into my array. I want to have the ability to shuffle all the questions after the user is done with a game and s开发者_StackOverflowtarts a new one.

This is really easy to implement - just shuffle the array! The problem I run into is saving things. With Shared Preferences, I can save the index (question the user was at) when they close the app. But when I shuffle the array, and they leave the app and go back in - the array is back to the default array so the shuffle is kind of moot. You obviously can't save arrays with shared prefs - so does anyone know a simple/easy way to save the shuffled array?


Serialize and http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

0

精彩评论

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