【发布时间】:2012-06-16 18:19:18
【问题描述】:
在我的 android 应用程序中,我编写了代码以读取另一个 Android 应用程序的共享数据,然后从共享首选项中删除该数据。 我的代码如下:
try {
con = createPackageContext("com.testapp.ws", 0);
SharedPreferences pref = con.getSharedPreferences("demopref", Context.MODE_PRIVATE);
ipAdr = pref.getString("demostring", "No Value");
pref.edit().remove("demopref").commit();
}
这显示以下错误:
06-12 11:52:07.400: E/ApplicationContext(3587): Couldn't rename file /data/data/com.testapp.ws/shared_prefs/demopref.xml to backup file /data/data/com.testapp.ws/shared_prefs/demopref.xml.bak
我在我的其他应用程序中使用此方法来制作共享数据
public void shareData(){
String strShareValue = ip;
SharedPreferences prefs = getSharedPreferences("demopref",Context.MODE_WORLD_READABLE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("demostring", strShareValue);
editor.commit();
}
我该怎么做?有什么要添加Manifest文件的吗?
谢谢!
【问题讨论】:
标签: android android-intent android-emulator