try {
Context mContext = createPackageContext("com.android.weather", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences sp =mContext.getSharedPreferences("com.android.weather_preferences",
MODE_WORLD_WRITEABLE);
String f = sp.getString("frequency", "0");
System.out.println("++++++++String from other project:::::" + f);
Editor editor = sp.edit();
editor.putString("frequency", "6");
editor.commit();
} catch (NameNotFoundException e) {
e.printStackTrace();
}
可以读其它应用的SharedPreferences
有时需要加上
getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_WRITEABLE);