In desktop application, usually, to store such application configuration
public class ApplicationConfiguration
{
public int speed;
public boolean soundEnabled;
public Map<Country, String> watchlistNames = new EnumMap<Country, String>(Country.class);
public List<BrokingFirm> brokingFirms = new ArrayList<BrokingFirm>();
}
I store it in XML, by using xstream, as they handle List
, Map
, other data structures quite well. Even for own custom class like Country
, BrokingFirm
, ... xstream handles them quite well too. Most of the time, we need not to provide explicit serialization code for custom class, as long as there is no fancy data structure within the custom class. xstream almost does all the hard work for us.
However, when come to Android, I'm not sure is there any good choice similar to xstream? Preferences doesn't seem to handle collection classes and custom class well? Or at least, quite a number of custom code required to make it work.
There is nothing out of the box in android to store your settings, also Shared Preferences
use XML too. so you can create your own class parser/serializer and store it as string and then deserialize it whenever you want to.