/** SharedPreferences简易存取。 */
public class Prefs {
    /**
     * 向首选项中设置值。</br>
     *
     * value的实际类型需要是<b>boolean</b>、<b>float</b>、<b>int</b>、<b>long</b>、<b>String</b>之一，否则不作处理。
     * */
    public static void put(Context context, String key, Object value) {
        Editor editor = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE).edit();

        if (value instanceof Boolean) {
            editor.putBoolean(key, (Boolean) value);
        } else if (value instanceof Float) {
            editor.putFloat(key, (Float) value);
        } else if (value instanceof Integer) {
            editor.putInt(key, (Integer) value);
        } else if (value instanceof Long) {
            editor.putLong(key, (Long) value);
        } else if (value instanceof String) {
            editor.putString(key, (String) value);
        } else {
            // 按说应该抛异常。
        }

        editor.commit();
    }

    /** 从首选项中取值。 */
    @SuppressWarnings("unchecked")
    public static <P> P get(Context context, String key, P defValue) {
        SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);

        Object result = null;

        if (defValue instanceof Boolean) {
            result = prefs.getBoolean(key, (Boolean) defValue);
        } else if (defValue instanceof Float) {
            result = prefs.getFloat(key, (Float) defValue);
        } else if (defValue instanceof Integer) {
            result = prefs.getInt(key, (Integer) defValue);
        } else if (defValue instanceof Long) {
            result = prefs.getLong(key, (Long) defValue);
        } else if (defValue instanceof String) {
            result = prefs.getString(key, (String) defValue);
        }

        return (P) result;
    }
}

@@ -1,12 +1,87 @@
+import android.content.Context;%0Aimport android.content.SharedPreferences;%0A%0A
 /** SharedPr
@@ -93,12 +93,13 @@
 nces
-%E7%AE%80%E6%98%93%E5%AD%98%E5%8F%96
+ CRUD
 %E3%80%82 */
@@ -131,58 +131,18 @@
  /**
-%0A     * %E5%90%91%E9%A6%96%E9%80%89%E9%A1%B9%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%80%BC%E3%80%82%3C/br%3E%0A     *%0A     * value%E7%9A%84%E5%AE%9E%E9%99%85%E7%B1%BB%E5%9E%8B%E9%9C%80%E8%A6%81%E6%98%AF
+ %3Cp%3EPut a 
 %3Cb%3Eb
@@ -151,17 +151,17 @@
 lean%3C/b%3E
-%E3%80%81
+/
 %3Cb%3Efloat
@@ -164,17 +164,17 @@
 loat%3C/b%3E
-%E3%80%81
+/
 %3Cb%3Eint%3C/
@@ -175,17 +175,17 @@
 %3Eint%3C/b%3E
-%E3%80%81
+/
 %3Cb%3Elong%3C
@@ -191,9 +191,9 @@
 %3C/b%3E
-%E3%80%81
+/
 %3Cb%3ES
@@ -205,25 +205,269 @@
 %3C/b%3E
-%E4%B9%8B%E4%B8%80%EF%BC%8C%E5%90%A6%E5%88%99%E4%B8%8D%E4%BD%9C%E5%A4%84%E7%90%86%E3%80%82%0A     *
+ value into%0A     *  preferences file named as %7B@linkplain Context#getPackageName() packageName%7D.%0A     *%0A     *  @throws IllegalArgumentException If The type of %3Ccode%3Evalue%3C/code%3E is not one of those.%0A     *  @see android.content.SharedPreferences.Editor%0A     * 
  */%0A
@@ -546,16 +546,34 @@
         
+SharedPreferences.
 Editor e
@@ -1170,79 +1170,500 @@
     
-// %E6%8C%89%E8%AF%B4%E5%BA%94%E8%AF%A5%E6%8A%9B%E5%BC%82%E5%B8%B8%E3%80%82%0A        %7D%0A%0A        editor.commit();%0A    %7D%0A%0A    /** %E4%BB%8E%E9%A6%96%E9%80%89%E9%A1%B9%E4%B8%AD%E5%8F%96%E5%80%BC%E3%80%82
+throw new IllegalArgumentException(%22Argument illegal, see JavaDocs.%22);%0A        %7D%0A%0A        editor.commit();%0A    %7D%0A%0A    /** %3Cp%3ERetrieve a %3Cb%3Eboolean%3C/b%3E/%3Cb%3Efloat%3C/b%3E/%3Cb%3Eint%3C/b%3E/%3Cb%3Elong%3C/b%3E/%3Cb%3EString%3C/b%3E value from preferences.%0A     *%0A     *  @return value corresponds to %3Ccode%3Ekey%3C/code%3E if %3Ccode%3Ekey%3C/code%3E exists,%0A     *  %3Ccode%3EdefValue%3C/code%3E otherwise.%0A     *  @see SharedPreferences%0A     *  @throws IllegalArgumentException If The type of %3Ccode%3EdefValue%3C/code%3E is not one of those.%0A     * 
  */%0A
@@ -1906,15 +1906,8 @@
 sult
- = null
 ;%0A%0A 
@@ -2447,32 +2447,132 @@
 alue);%0A        %7D
+ else %7B%0A            throw new IllegalArgumentException(%22Argument illegal, see JavaDocs.%22);%0A        %7D
 %0A%0A        return

Update Prefs - Updated comments into English.