D
D
druper2020-07-29 11:51:56
Android
druper, 2020-07-29 11:51:56

How to organize multiple versions of application settings?

The user can connect to different addresses of a particular service. It is necessary to load the settings when changing the connection. The list of settings is the same everywhere.
Regardless of prefName, the same settings are loaded:

//        String prefName = "foo";
        String prefName = "bar";
        PreferenceManager.setDefaultValues(this, prefName, Context.MODE_PRIVATE,
                R.xml.root_preferences, false);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
one pavel, 2020-07-29
@onepavel

for each connection address, you can create a
separate preference xml file using the SharedPreferences context
getSharedPreferences(String name, @PreferencesMode int mode);

D
Developer, 2020-07-29
@samodum

If the number of addresses is strictly limited, then they can be registered in Gradle both as parameters and as different versions / types of application builds.
Another option is to load a list of addresses via the API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question