Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { private static SharedPreferences pref = null; public static SharedPreferences getSharedPreferences(Context context) { if (pref != null) return pref; if (context != null) { pref = PreferenceManager.getDefaultSharedPreferences(context); return pref; } return pref; } }