In my app, I use a PreferenceActivity framework to store persistent data. My intent is to create multiple save files, all of which may be accessed by the Preferences, but only one at a time.
When is it better to use a private file generated by Context.openFileOutput() and when is it better to use SharedPreferences?
EDIT
My data exists solely in primitives.
Normally developers use a preference file that is common to an entire app using
getDefaultSharedPreferences.However, Android has a
getSharedPreferences(String name, int mode)method in Context. You could use this to have multiple preference files, in your case – save files, by using unique names passed into thenameparameter.Regarding volatility, you can force the preferences to save by getting an
Editorviaedit()and then callingcommit().Make sure to note that the SharedPreferences will indeed be shared based on the
name: