Reputation: 41759
I usually use one preference XML file to store all app-wide data. Now I wonder if this is a wrong way to do. When should I use multiple preference files?
After checking my sdcard I found many preference XML files and it seems that many apps use a single preference file as well.
Upvotes: 3
Views: 572
Reputation: 15108
I would suggest the same approach as with software development in general.
High Cohesion and Low Coupling. Meaning to tie preferences to the module that is responsible for them.
Of course it doesn't matter if we only talk about ~10 values.
Upvotes: 2
Reputation: 8719
Multiple preference files might be useful to manage settings across multiple users. For instance, if I were writing a Twitter client that allowed multiple Twitter accounts, I could generate a separate preferences file for each individual account.
Upvotes: 2
Reputation: 8132
I have never run into a situation where I chose to use anything but the default SharedPreferences
for storing preferences. As long as you don't use overlapping names for different preferences, it should be fine.
That said, I also don't see any real downside to using multiple files, as the user should never see them anyways, and I would think any performance hit would be extremely minor, unless you are storing complicated things in preferences.
Upvotes: 1