在java bean业务层设置sharedperferences
package cn.zs.service;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class PreferencesService {
private Context context;
public PreferencesService(Context context) {
this.context = context;
}
/**
* 保存姓名
* 保存年龄
* @param name
* @param age
*/
public void save(String name, Integer age) {
SharedPreferences preferences = context.getSharedPreferences("itcast", Context.MODE_PRIVATE);//私有属性
Editor editor = preferences.edit();
editor.putString("name", name);
editor.putInt("age", age);
editor.commit();//把内存中提交到文件中
}
/**