Sharedpreference sp = getSharedPregetSharedPreferences(WeatherInfoProvider._TAG,Context.MODE_PRIVATE);
sp.editor.putString("Brief","_Brief");
sp.editor.putString("IconCode,","_IconCode");
sp.editor.commit();
会出现保存不了的情况,因为每个sp.editor返回一个Sharedpreference.Editor对象,而不是同一个对象,导致最后commit的时候也不是同个对象,数据就存储不起来了!
正确的写法是:
Sharedpreference.Editor sp = getSharedPregetSharedPreferences(WeatherInfoProvider._TAG,Context.MODE_PRIVATE).edit();
sp.putString("Brief","_Brief");
sp.putString("IconCode,","_IconCode");
sp.commit();
-在多进程的时候同时去修改值什么的会出现问题!