Android 关于访问SharedReference的另一个应用程序

Android 关于访问SharedReference的另一个应用程序,android,Android,我需要访问另一个应用程序的SharedReference,必须设置SharedReference MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE,并显示Logcat 03-23 13:54:45.038: E/ApplicationContext(10895): Couldn't rename file /data/data/com.mzw.gamehelper/shared_prefs/public.xml to backup file /data/dat

我需要访问另一个应用程序的SharedReference,必须设置SharedReference

MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE,并显示Logcat

03-23 13:54:45.038: E/ApplicationContext(10895): Couldn't rename file /data/data/com.mzw.gamehelper/shared_prefs/public.xml to backup file /data/data/com.mzw.gamehelper/shared_prefs/public.xml.bak

我不知道有什么问题,谁能帮我,谢谢。

试试这段代码插入值

 private SharedPreferences myPrefs;
    myPrefs = Actionactivity.this.getSharedPreferences("myPrefs", MODE_WORLD_WRITEABLE);
    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefsEditor.putString("Mobile_no", getText_no.getText().toString().trim());
    prefsEditor.commit();
并尝试此代码获取值

myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
myPrefs.getString("Mobile_no", "");
试着这样做:

Context otherAppsContext = null;
private SharedPreferences sharedPreferences;
public static final String PREFS_READ = "PREFS_READ";
public static final String KEY_READ = "KEY_READ";
try {
  //com.dfdf.fdfdf.android.sharedpreferences OTHER APPLICTION PACKAGE NAME
       otherAppsContext = createPackageContext("com.dfdf.fdfdf.android.sharedpreferences", 0);
    } catch (NameNotFoundException e) {
    }
 sharedPreferences = otherAppsContext.getSharedPreferences(PREFS_READ, Context.MODE_WORLD_WRITEABLE);
 String strvalue=sharedPreferences.getString(KEY_READ, "WORLD READ EMPTY")

我可以获取值,这没问题,但无法更改值,抛出异常。mContext=this.createPackageContextpackName,Context.Context\u IGNORE\u SECURITY;SharedReferences spf2=mContext.getSharedReferencesPublic,模式为“可写”模式为“可读”;编辑器编辑器=spf2.edit;editor.putBooleanpreview,true;editor.putinoverlay_尺寸,100;editor.commit;