Post Reply

[Q] XSharedPreferences - never loaded

OP TheLexus

18th August 2014, 07:47 AM   |  #1  
OP Senior Member
Thanks Meter: 12
 
139 posts
Join Date:Joined: Jun 2011
Hi guys,

I'm currently a little bit confused because i try to create my first XPosed module for Xposed 2.6.1 on a Android 4.0.3 unit but i have trouble with my preferences. I tried multiple things but it was never working.

Here is the preferences code of my Settings activity. That one works and it creates a the preference file with rw-rw-r permissions and the preferences are correctly saved.

Code:
getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE | MODE_MULTI_PROCESS);
getPreferenceManager().setSharedPreferencesName(Const.PACKAGE + "_preferences");
addPreferencesFromResource(R.xml.preferences);
That one is the xposed side snippet:

Code:
preferences = new XSharedPreferences(Const.PACKAGE, Const.PACKAGE+"_preferences");
if (preferences.getAll().size()==0)
{
  debug("Preferences seems not to be initialized!");
}
It never loads any of my preferences. I tried the constructor XSharedPreferences(Const.PACKAGE) instead, but without any luck...

I checked the directory permissions of the settings directory, and that one seems to be correct (rwxrwxr-x).

Thanks for every help!

Bye
Last edited by TheLexus; 18th August 2014 at 08:02 AM.
18th August 2014, 10:57 AM   |  #2  
theknut's Avatar
Senior Member
Thanks Meter: 3,233
 
871 posts
Join Date:Joined: May 2009
Donate to Me
More
Have you checked what Const.PACKAGE actually is set to?
18th August 2014, 04:08 PM   |  #3  
OP Senior Member
Thanks Meter: 12
 
139 posts
Join Date:Joined: Jun 2011
It is set to the hardcoded package Name. No class.getPackage... I added a file.isreadable and it returns false. I dont know, im just out oft any ideas.
18th August 2014, 04:17 PM   |  #4  
theknut's Avatar
Senior Member
Thanks Meter: 3,233
 
871 posts
Join Date:Joined: May 2009
Donate to Me
More
Quote:
Originally Posted by TheLexus

It is set to the hardcoded package Name. No class.getPackage... I added a file.isreadable and it returns false. I dont know, im just out oft any ideas.

Is there any reason why you set MODE_MULTI_PROCESS? Can you please try removing it, delete your preference file and try again?
In my UI I open SharedPreferences from <packagename>_preferences.xml
Quote:

getSharedPreferences(Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE)

and in the module I open the settings via
Quote:

new XSharedPreferences(Common.PACKAGE_NAME);

Please remove your current preferences file and the MODE_MULTI_PROCESS and try the code from above.
13th October 2014, 04:30 PM   |  #5  
Senior Member
Thanks Meter: 29
 
150 posts
Join Date:Joined: Mar 2011
So you found any way to make it work??
I ran into the same problem, I set the preferences by the code:
SharedPreferences.Editor editor = LogExtras.getAppContext().getSharedPreferences(Com mons.PACKAGE_NAME, Context.MODE_WORLD_READABLE).edit();
editor.putString("package_to_look", _packageToLook);

And when I try to get it from the module it always returns size 0
private static final XSharedPreferences preferences = new XSharedPreferences(Commons.PACKAGE_NAME, Commons.PACKAGE_NAME+"_preferences");

public static void refreshPreferences() {
Log.d("Utils", "reading prefs");
preferences.reload();
Log.d("Utils", Integer.toString(preferences.getAll().size()));
Commons.PACKAGE_TO_LOOK = preferences.getString("package_to_look", Commons.PACKAGE_TO_LOOK);
log("Package to Look: " + Commons.PACKAGE_TO_LOOK);
}

---------- Post added at 04:30 PM ---------- Previous post was at 03:34 PM ----------

I tested the prefs in the context, and it works, only in xposed it dont load.
So I got the app saving the pref and reading the pref working, but when I try to read the pref with XSharedPreference, the size is always 0.
Already tried everything, but nothing works.
Post Reply Subscribe to Thread

Tags
xsharedpreferences xposed
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Xposed General by ThreadRank