Reputation: 16415
I am currently working on an application where the user is presented with a series of lists, clicking on each list the user is taken to another list based on his selction. Now in order to remember what the user does on each screen, i insert a series of strings into my Shared Preferences. As it turns out, as my app has about 7 8 selection screens, my whole code is just tangled up with reading and writing keys from the shared preferences.
air_conditioning = Session.getBoolean(SELL_AIR_CONDITIONINING) ? "1" : "0";
power_steering = Session.getBoolean(SELL_POWER_STEERING) ? "1" : "0";
power_locks = Session.getBoolean(SELL_POWER_LOCKS) ? "1" : "0";
power_mirrors = Session.getBoolean(SELL_POWER_MIRROR) ? "1" : "0";
keyless_entry = Session.getBoolean(SELL_KEYLESS_ENTRY) ? "1" : "0";
cruise_control = Session.getBoolean(SELL_CRUISE_CONTROL) ? "1" : "0";
navigation_system = Session.getBoolean(SELL_NAVIGATION_SYSTEM) ? "1" : "0";
abs = Session.getBoolean(SELL_ABS) ? "1" : "0";
am_fm_radio = Session.getBoolean(SELL_FM_AM_RADIO) ? "1" : "0";
cassette_player = Session.getBoolean(SELL_CASSETE_PLAYER) ? "1" : "0";
cd_player = Session.getBoolean(SELL_CD_PLAYER) ? "1" : "0";
sun_roof = Session.getBoolean(SELL_SUN_ROOF) ? "1" : "0";
alloy_rims = Session.getBoolean(SELL_ALLOW_RIMS) ? "1" : "0";
So this is basically my whole code, which looks ugly, prone to errors, and not very maintainable. I was looking for any solution that would serve me in this case.
Kind Regards
Upvotes: 1
Views: 367