android 通过SharedPreferences 保存状态

		//获取到sharepreference 对象, 参数一为xml文件名,参数为文件的可操作模式 
		SharedPreferences sp = this.getSharedPreferences("customerstatus", MODE_APPEND);  
		
		//获取到编辑对象
		SharedPreferences.Editor edit = sp.edit();  
		
		edit.putString("sysNo", "1");
		edit.putString("account", "yiminhu");
		//添加新的值,可见是键值对的形式添加
		edit.commit();
		//@SuppressWarnings("deprecation")
		SharedPreferences share=getSharedPreferences("customerstatus",Activity.MODE_WORLD_READABLE);

		Log.d("SP", share.getString("account", "none"));

猜你喜欢

转载自yiminhu.iteye.com/blog/2168607
今日推荐