다른 App의 Preference xml 파일 값을 읽어오고 쓰는 과정에서
문의드립니다.
Application A
A 앱은 test.xml 파일에 ment key 값으로 hello 를 써놓은 상태입니다.
pref = getSharedPreferences("test", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);
editor = pref.edit();
editor.putString("ment", "hello");
editor.commit(); |
Application B
B앱은 A의 Preference 파일(test.xml)의 ment key 값을 읽고 bye라고 썼습니다.
try {
mContext =createPackageContext("com.pref1", Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
pref = mContext.getSharedPreferences("test", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
SharedPreferences.Editor editor = pref.edit();
editor.putString("ment", "bye");
editor.commit();
Log.d(TAG, "ment= " + pref.getString("ment", "nothing"); //bye로 찍힘
|
Application B에서 write후 Log를 찍어보면 bye로 읽혀집니다.
하지만, data/data/A의PackageName/shared_prefs/test.xml 파일을 열어보면
hello로 가지고 있습니다.
분명히 B에서 wirte를 했지만, B의 로그상에서는 바뀐것으로 표시되지만
실제 파일을 열어보면 값이 변경되지 않았습니다.
이 부분이 왜 이러는 걸까요 ㅠ.ㅠ
이래저래 구글링해봐도 이유를 찾을수가 없네요.
아시는 분의 답변 쫌 부탁드립니다.