 |
在Activity中使用SharedPreferences sp=this.getSharedPreferences("zhy", this.MODE_WORLD_WRITEABLE);其中zhy是文件的名字,不包含扩张名。就可以获得一个SharedPreferences的对象,使用SharedPreferences的对象就可以从xml中获得数据。 写数据时, Editor editor=sp.edit(); editor.putInt("hight",value); editor.commit(); 不要忘记editor.commit()。
| |