Access to general settings from different actions (Android)

When you set general preferences like below ...

public static final String PREFS_HI = "MyPrefsFile";

Is it possible to access it from other actions, as usual?

SharedPreferences settings = getSharedPreferences(PREFS_HI, 0);

Or is there something unique that you have to do to access the settings?

+5
source share
3 answers

I thought about it myself. I just used global variables and stored sharedpreferences inside. When another action wanted to access the settings, it would simply gain access to the global variable.

+1
source

( PREFS_HI) XML (strings.xml). getSharedPreferences(getResources().getString(R.string.sharedPrefs)). . ( .)

+3

getApplication (). getSharedPreferences (name, mode) try this

0
source

All Articles