I have an application which uses two sharedpreferences (so two xml files) to operate. They are added in my eclipse project, I can see both under /res/xml as two files: preferences.xml and service_data.xml.
When I compile and run my program, it compile OK without problems or warnings, but when executed is like preferences.xml does not load. I open DDMS view, and with file explorer I can see under /data/data/com…myapp/shared_prefs that only service_data.xml has been installed and copied. There is no preferences.xml.
In my app, I open both with (in this order):
SharedPreferences preferences = this.getSharedPreferences("preferences",0);
SharedPreferences service_data = this.getSharedPreferences("service_data",0);
Xml files looks correct, and in fact preferences.xml were running ok before I added service_data.xml
Has someone an idea why preferences.xml is not installed and not opened? any tip of the possible cause?
Thanks
Solved.
Initially, Android does not create an xml for preferences. Only when a new preference is going to be created that is not the default value is the xml file added. So it is necessary that all references to preferences.getString has the proper default value.