[b][size=x-large]一.添加数据[/size][/b]
[b][size=x-large]二.获取数据[/size][/b]
SharedPreferences share = super.getSharedPreferences(FILENAME,
Activity.MODE_PRIVATE); // 指定操作的文件名称
SharedPreferences.Editor edit = share.edit(); // 编辑文件
edit.putString("author", "LiXingHua") ; // 保存字符串
edit.putInt("age", 30); // 保存整型
edit.commit() ;
[b][size=x-large]二.获取数据[/size][/b]
SharedPreferences share=getSharedPreferences(FILENAME, MODE_PRIVATE);
txt.setText("author:"+share.getString("author", "无名氏")+",age:"+share.getInt("age", 0));