Tôi cố gắng để sửa SharedPreferences
của một ứng dụng thông qua ứng dụng khác, mã của tôi đi như thế nàyAndroid: Không thể tạo thư mục cho SharedPreferences nộp
try {
Context plutoContext = getApplicationContext().createPackageContext("me.test",Context.MODE_WORLD_WRITEABLE);
SharedPreferences plutoPreferences = PreferenceManager.getDefaultSharedPreferences(plutoContext);
Editor plutoPrefEditor = plutoPreferences.edit();
plutoPrefEditor.putString("country", "India");
plutoPrefEditor.commit();
}
Tôi nhận được một lỗi
E/SharedPreferencesImpl( 304): Couldn't create directory for SharedPreferences file /data/data/me.test/shared_prefs/me.test_preferences.xml
nơi me.test
là một dự án khác của tôi trong me.test proj Tôi có thể chỉnh sửa và truy xuất SharedPreferences
mà không bị đau
Tôi đang thử nghiệm trên Nexus S android 4.0.4 (Samsung), bất kỳ ai có thể giúp tôi
Dự án "me.test" của bạn đã tạo SharedPreferences với 'MODE_WORLD_WRITEABLE'? – WarrenFaith
@ WarrenFaith, cảm ơn nhận xét. Tôi không biết làm thế nào để tạo ra 'MODE_WORLD_WRITEABLE' với, tôi chỉ tạo ra bình thường –
Bạn cũng có thể viết loại ngoại lệ? – teoREtik