0
「錯誤」: html_value1不是 「」的Android的Java Sharedpreferences將不保存數據
MainActivity:
tools.getEditor(tools.getPreferences(getApplicationContext())).putString("wochea9a", html_value1);
tools.getEditor(tools.getPreferences(getApplicationContext())).putString("wocheb9a", html_value2);
tools.getEditor(tools.getPreferences(getApplicationContext())).commit();
Alarmserviceactivity:
savedwochea9a = tools.getPreferences(getApplicationContext()).getString("wochea9a", "error");
savedwocheb9a = tools.getPreferences(getApplicationContext()).getString("wocheb9a", "error");
個工具:
public class tools {
static SharedPreferences preferences;
static SharedPreferences.Editor editor;
public static SharedPreferences getPreferences(Context context){
preferences = PreferenceManager.getDefaultSharedPreferences(context);
return preferences;
}
public static SharedPreferences.Editor getEditor(SharedPreferences preferences){
editor = preferences.edit();
return editor;
}
...
我該如何解決這個問題?