Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,356 Members 38,609 Now Online
XDA Developers Android and Mobile Development Forum

[Q] XSharedPreferences - never loaded

Tip us?
 
TheLexus
Old
(Last edited by TheLexus; 18th August 2014 at 08:02 AM.)
#1  
Senior Member - OP
Thanks Meter 9
Posts: 134
Join Date: Jun 2011
Default [Q] XSharedPreferences - never loaded

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
 
theknut
Old
#2  
theknut's Avatar
Senior Member
Thanks Meter 3,094
Posts: 829
Join Date: May 2009

 
DONATE TO ME
Have you checked what Const.PACKAGE actually is set to?
[MOD][XPOSED] Xposed GEL Settings - Customize your Google Now Launcher
[MOD][XPOSED] Suggestions Toggle - Quickly toggle keyboard suggestions on/off
[MOD][XPOSED] No Wireless Charging Sound - Disables the "Wireless charging started" sound
 
TheLexus
Old
#3  
Senior Member - OP
Thanks Meter 9
Posts: 134
Join Date: 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.
 
theknut
Old
#4  
theknut's Avatar
Senior Member
Thanks Meter 3,094
Posts: 829
Join Date: May 2009

 
DONATE TO ME
Quote:
Originally Posted by TheLexus View Post
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.
[MOD][XPOSED] Xposed GEL Settings - Customize your Google Now Launcher
[MOD][XPOSED] Suggestions Toggle - Quickly toggle keyboard suggestions on/off
[MOD][XPOSED] No Wireless Charging Sound - Disables the "Wireless charging started" sound
Tags
xsharedpreferences xposed
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes