sharepreference用法
1.本程序
//MODE_PRIVATE 指定该sharepreferences的数据只能被本程序读写
//MODE_WORLD_READABLE 被其他数据能读不能写
//MODE_WORLD_WRITEABLE 数据可以被其他数据读写
SharedPreferences preferences;
preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
Editor editor = preferences.edit();
editor.putInt("count", ++count);
editor.commit();
2. 文件保存在data/data/<package name>/shared_prefs目录下
3.读其他程序的SharePreferences
Context usecount = null;
useCount = createPackageContext("org.crazyit.io",Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefs = useCount.getSharedPreferences("count",Context.MODE_WORLD_READABLE);
int count = prefs.getInt("count",0);