Xsharedpreference Failing to read prefs file above SDK 24
Closed this issue · 6 comments
i m put preference like this
edt = pref.edit(); String imei = edt_imei.getText().toString().trim(); edt.putString("imei", imei); edt.commit(); tx_imei1.setText("IMEI: " + imei);
i m trying:
`public static XSharedPreferences init() {
if (Build.VERSION.SDK_INT > 23) {
File file = new File("/data/user/0/com.yuvi.myapplication111/shared_prefs/user_prefs.xml");
File file2 = new File("/data/user_de/0/com.yuvi.myapplication111/shared_prefs/user_prefs.xml");
if (file.exists() && file.canRead()) {
pref = new XSharedPreferences(file);
} else if (!file2.exists() || !file2.canRead()) {
pref = new XSharedPreferences("com.yuvi.myapplication111", "user_prefs");
pref.makeWorldReadable();
pref.reload();
} else {
pref = new XSharedPreferences(file2);
pref.reload();
pref.makeWorldReadable();
}
} else {
pref = new XSharedPreferences("com.yuvi.myapplication111", "user_prefs");
pref.makeWorldReadable();
pref.reload();
}
return pref;
`
but still giving default vale 200000000000000 :
` try {
XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", loadPackageParam.classLoader, "getDeviceId", new XC_MethodHook() {
public void afterHookedMethod(XC_MethodHook.MethodHookParam methodHookParam) {
methodHookParam.setResult(Xshare.get("imei", "200000000000000"));
}
});
} catch (Exception e) {
e.printStackTrace();
}`
You're doing it all wrong.
https://github.com/ElderDrivers/EdXposed/wiki/New-XSharedPreferences
You're doing it all wrong.
https://github.com/ElderDrivers/EdXposed/wiki/New-XSharedPreferences
Can you explain more please ?? what i did wrong
Notice that you cannot use the XSharedPreferences(File prefFile) because the preference file is stored in a random directory.
Modules developers can enable this new XSharedPreferences support by modifying the meta-data of your modules to set xposedminversion to 93 or above, or add xposedsharedprefs meta-data.
To read the preference from the hooked app, you can simply use XSharedPreferences(String packageName) or XSharedPreferences(String packageName, String prefFileName) to retrieve the preference.
Modules developers can enable this new XSharedPreferences support by modifying the meta-data of your modules to set xposedminversion to 93 or above, or add xposedsharedprefs meta-data.
To read the preference from the hooked app, you can simply use XSharedPreferences(String packageName) or XSharedPreferences(String packageName, String prefFileName) to retrieve the preference.
<meta-data
android:name="xposedsharedprefs"
android:value="true" />
Is it right way??
adding xposedsharedprefs support