My first attempt at preferences was without knowledge of PreferenceActivity
. So now I have an app that stores all user preferences in a specific preference file.
I want to migrate to using a PreferenceActivity but I also want my users to keep their preferences.
Is there a way to tell my PreferenceActivity to use that specific file for all preferences?
You could read all the preferences at the beginning of your app, and then store them in the
Preferences
usingI hope that helps
It may be too late to post this but you can find a nice solution here
You set the name of the default shared preferences file beforehand like this:
I hope this helps somebody.
Regards.
Maaalte is correct, what you want to do is onCreate test for the existence of your custom file and if it's there, rename it to standard shared preferences filename.
Another option is to read your old prefs one-by-one and use the shared preferences API to add them as you read them and then delete your old prefs when you are done.