Frank Bozzo
Frank Bozzo

Reputation: 15403

Using Static Methods to handle a large list of SharedPrefs... Is this a good idea?

I am writing a game for Android that requires a ton of simple data (stats, map locations etc...) to be stored in SharedPreferences.

To simplify and streamline this process I created a Settings class that uses static set and get methods for all the sharedprefs. Then I simply call settings.getXYZ() from anywhere else in the app.

Lately I have read that using static methods in Android is a bad idea in the long run. Is there a better way to accomplish this?

Upvotes: 0

Views: 85

Answers (2)

Zappescu
Zappescu

Reputation: 1439

For a big set of values to be stored I suggest you to use a sqlite db instead of sharedpreferences. It is easier to manage and not difficult to learn to use it.

Upvotes: 0

Codeman
Codeman

Reputation: 12375

I would recommend you have a set of static methods in a public class designed to get and set any preferences as properties.

This is how I have it setup in my apps, and it works great! As long as you treat them as static objects, you should have no issues.

Upvotes: 1

Related Questions