Android:修改另一个应用程序的SharedPreferences [英] Android: Modify SharedPreferences of another app
问题描述
我正在尝试编写必须读取,修改并保存其他应用程序的共享首选项中的某些设置的应用程序( data/data/package_name/shared_prefs/file.xml
).
I'm trying to write application that must read, modify and save some settings in Shared preferences of another application (data/data/package_name/shared_prefs/file.xml
).
该应用程序不是我的应用程序,我已经植根了用于测试的设备.
This application isn't mine, and I have rooted device for testing.
我应该添加到清单中的哪些android权限,以及如何访问此文件并对其进行修改?我知道 SharedPreferences
对于每个App/APK都是唯一的,但是我需要在root模式下对其进行修改.
What android permissions i should add to manifest and how can I access this file and modify it? I know that SharedPreferences
are unique to each App/APK, but I need to modify it in root mode.
我有工作代码来修改sdcard上的xml文件,但是当我将路径更改为"data/data/package_name/shared_prefs/file.xml"
时,它给了我一个异常和消息
I have working code to modify xml file on sdcard, but when I change path to "data/data/package_name/shared_prefs/file.xml"
it gives me an exception and message
android open failed eacces (permission denied)
有没有办法可以做到这一点?
Is there a way I can achieve that?
推荐答案
看看这个答案:
https://stackoverflow.com/a/13139280/361230
使用su时,您将有权修改文件系统上想要的任何内容.
When you use su, you will have the permission to modify whatever you want on the filesystem.
但是,我同意Chris的观点,那就是做你想做的事真的不是一件好事.
However, I agree with Chris on the fact it's not really nice to do what you want to.
这篇关于Android:修改另一个应用程序的SharedPreferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!