Android examples for android.content:SharedPreferences
get String Preferences
import java.util.HashMap; import java.util.Map; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { public static Map<String, String> getStringPreferences(Context context, String... prefNames) { SharedPreferences preferences = getDefaultPreference(context); Map<String, String> prefMap = new HashMap<String, String>(); for (String name : prefNames) { prefMap.put(name, preferences.getString(name, "")); }/* w ww . j a va 2s.c om*/ return prefMap; } public static SharedPreferences getDefaultPreference(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); } }