1:访问sharedpreference
A.apk 访问 B.apk中的sharedpreference
B.apk
Activity中
SharedPreferences settings = getSharedPreferences("name_preferences" ,Context.MODE_WORLD_READABLE);
androidmanifest.mk中
package="com.eddy.android.name_preferences"
A.apk
Activity中
SharedPreferences settings;
Context otherAppContext;
try {
otherAppContext = createPackageContext("com.eddy.android.name_preferences", Context.CONTEXT_IGNORE_SECURITY);
settings = otherAppContext.getSharedPreferences("com.eddy.android.name_preferences",Context.MODE_WORLD_READABLE);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
androidmanifest.mk中
android:sharedUserId="com.eddy.android.name_preferences" //--为B.apk 的package