在A中通过createPackageContext(B.packagename, INCLUDE_CODE)获得B的context实例,之后我通过B对文件数据修改,退出B,A中再通过context
解决办法,修改getsharedpreference("config",otherAppsContext.MODE_WORLD_READABLE)的权限MODE_WORLD_READABLE修改为
下面是MODE_MULTI_PROCESS
的说明:
SharedPreference loading flag: when set, the file on disk will be checked for modification even if the shared preferences instance is already loaded in this process. This behavior is sometimes desired in cases where the application has multiple processes, all writing to the same SharedPreferences file. Generally there are better forms of communication between processes, though.
This was the legacy (but undocumented) behavior in and before Gingerbread (Android 2.3) and this flag is implied when targetting such releases. For applications targetting SDK versions greater than Android 2.3, this flag must be explicitly set if desired.