Back to project page java-androidframework.
The source code is released under:
This project is licensed under the [CC0 1.0 Agreement](http://creativecommons.org/publicdomain/zero/1.0/). To the extent possible under law, Pete Schmitz has waived all copyright and related or neigh...
If you think the Android project java-androidframework 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 com.gamepatriot.framework2d.implementation; /*from www .j a va2s.co m*/ import android.app.Activity; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import com.gamepatriot.androidframework.framework.AndroidGameData; /** * The GameData class is used to save and load dynamic data associated with the application. * * @see AndroidGameData * @author Pete Schmitz, May 8, 2013 * */ public class GameData implements AndroidGameData { /** The unique save path to use for this application. **/ public static String SAVE_PATH = "AndroidFramework"; //References /** The reference to this applications {@link Main} object. **/ private Main main; /** * @param $main Instantiated main class, primary activity of the application. */ public GameData(Main $main){ main = $main; load(); } @Override public void save() { Editor $editor = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE).edit(); //$editor.putInt("levels", levels); $editor.commit(); } @Override public void load() { SharedPreferences $sharedPreferences = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE); //levels = $sharedPreferences.getInt("levels", DEFAULT_LEVELS); } @Override public void clear() { Editor $editor = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE).edit(); $editor.clear().commit(); } @Override public void reset() { clear(); load(); } }