2011年4月4日 星期一

[Android] Preference

How to save preference or confign in a activity.



How to get preference in a activity.


You can also use SharedPreference to get and set preference inter activitys like this.

SharedPreferences setting = getSharedPreferences("PreferenceName", 0);

int value;
SharedPreferences setting = getPreferences(MODE_PRIVATE);
value = setting.getInt("Tag", 0);

int value = 0;
SharedPreferences setting = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor prefEditor = setting.edit();
prefEditor.putInt(“Tag”, value);
prefEditor.commit();

沒有留言:

張貼留言