[Java for Android App Development] StevenStanleyBayes:
I try to get shared preferences in the exposed class.

This is a straight forward issue in android java. I do not know whether the permissions are the problem but things are not as straight with Xposed.

Xposed asks to provide the name of the file and the package at init Zigote. I have tried many versions and none of them seems to work. Also, the file which I make may not be available when init Zygote is called, however, I take XposedBridge wants to just register the name of the file and, probably, to prepare to override some permissions when the file is created.

I also try to double the call to the Xposed Shared Method inside the hooked method. I check for the existence of the shared preference file before. Everything is there but the reload method does not seem to reload and the file is not read but defaults are loaded by getInt and getFloat.

There is probably something more to be done, although the examples I have seen do not do anything, yet they override other methods inside init Zygote which I do not need to do.

All I need is to read a simple file from an Xposed Module.

PLEASE, INFORM.

Here is what I have tried :

I have tried many different variation and XposedBridge methods for 4 hours. I have also

tried many name variations with and without .xml.

In the standard Java for Android, there is just one get method to read a shared

preferences file. This does not seem to be the case with exposed.

I do have :

[MENTION=439709]override[/MENTION]

public void initZygote(StartupParam startupParam) throws Throwable {

MODULE_PATH = startupParam.modulePath;

prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");

}

MODULE_PATH is not used, although I have tried many other methods where was.

Because the file changes on the fly, I called :

prefs.reload();

before I read the data. I tried without this call too. I also tried to get another

prefs before the reload :

prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");

prefs.reload();

Then I try to read the data from the file :

theStart=prefs.getInt("Start", 2);

theValue=prefs.getFloat("Value", 102.0f);

I always get the defaults 2 and 102.0 although the file is there and the values of the

file are different. I have read the file.

In standard java for android philosophy, just the initialisation in init zygote and

prefs.reload() are sufficient to load the changing values of the shared preferences

file into prefs and then into the variables.

Xposed seems to be different.

I have been told there is a way to read the data from the file. I have tried most

anything and cannot. What is the way to do so. Must be simple and straight as in the

standard java for android. I must not do everything necessary.

Please, inform.

I have also tried to read the file manually from the Xposed class. Access denied. Tried

just in cases. Access denied, again.

Tried to make the shared preferences file with Activity.MODE_WORLD_READABLE. Still

access denied to be read manually.

Even with Activity.MODE_WORLD_READABLE, Xposed cannot read the file as previously

explained.

Tried :

[MENTION=439709]override[/MENTION]

public void initZygote(StartupParam startupParam) throws Throwable {

prefs = new XSharedPreferences(TheNameOfTheXposedClass.class.getPackage().getName

());

prefs.makeWorldReadable();

}

Then, in the hooked method :

prefs.reload();

theStart = prefs.getInt("Start", 2);

theValue = prefs.getFloat("Value", 102.0f);

Still returns only the default, although the file is there. I think, in all attempts,

XSharedPreferences() cannot get the name of the package and or or the name of the file.

The file is in /data/data/NameOfPackage/shared_prefs/NameOfFile.xml

Tried :

[MENTION=439709]override[/MENTION]

public void initZygote(StartupParam startupParam) throws Throwable {

prefs = new XSharedPreferences

("/data/data/NameOfPackage/shared_prefs/NameOfFile.xml");

prefs.makeWorldReadable();

}

with and without .xml

Still nothing.