how to getSharedPreferences in dialog?
i want to read file in dialog
can any开发者_StackOverflow社区 one guide me how to achieve this?
when i use
SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE); in dialog it gives me error "method is undefined"
Use the Context
to access the preferences.
context.getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE);
You can get the context using super.getContext()
:
super.getContext().getSharedPreferences(PREFS_NAME, 0);
精彩评论