Back to project page androidtbsgame.
The source code is released under:
MIT License
If you think the Android project androidtbsgame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.mmssb.androidtbsgame.andengine.managers; //from ww w.ja va2 s . c om import java.util.Map; import java.util.TreeMap; import android.content.Context; import android.content.SharedPreferences; import de.mmssb.androidtbsgame.andengine.BoardMap; import de.mmssb.androidtbsgame.andengine.Model; /** * @author Manu * */ public class SharedPreferencesManager extends Manager { public static final String KEYFRONT_MAP = String .valueOf("<MAP>".hashCode()); private Map<String, BoardMap> mapStorage; private int dollars; /** * Creates an instance of {@link SharedPreferencesManager} * * @param model * {@link Model} reference */ public SharedPreferencesManager(Model model) { super(model); mapStorage .put("Level 1", new BoardMap( "[60/60]PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFFFFFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPPFPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFFFPPPFPPFPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPFPPFPPFPPPPPPPPPPPPPPPPPPPPP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PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP")); } @Override public void load() { mapStorage = new TreeMap<String, BoardMap>(); SharedPreferences prefs = getModel().getMainActivity().getPreferences( Context.MODE_PRIVATE); for (String key : prefs.getAll().keySet()) { if (key.startsWith(KEYFRONT_MAP)) { mapStorage.put(key.substring(KEYFRONT_MAP.length()), new BoardMap(prefs.getString(key, null))); } } dollars = prefs.getInt("dollars", 0); } public void save() { SharedPreferences.Editor editor = getModel().getMainActivity() .getPreferences(Context.MODE_PRIVATE).edit(); for (String key : mapStorage.keySet()) { editor.putString(KEYFRONT_MAP + key, mapStorage.get(key).toString()); } editor.putInt("dollars", dollars); editor.commit(); } public Map<String, BoardMap> getMapStorage() { return mapStorage; } public int getDollars() { return dollars; } public void setDollars(int dollars) { this.dollars = dollars; } }