@@ -0,0 +1,1665 @@
+package com.mengdd.utils.android;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0Aimport android.preference.PreferenceManager;%0A%0Apublic class PrefUtils %7B%0A    private class PrefFile %7B%0A        //you can define different preferences file name here%0A        public static final String SETTINGS = %22settings_preferences%22;%0A    %7D%0A%0A    public class PrefKey %7B%0A        //you can define the preferences keys here%0A        public static final String USER_NAME = %22user_name%22;%0A        public static final String APP_FIRST_LAUNCH = %22app_first_launch%22;%0A    %7D%0A%0A%0A    //Provide get/set methods for every key%0A%0A%0A    public static void setPrefUserName(final Context context, String userName) %7B%0A        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);//use default sharedPreferences here%0A        sp.edit().putString(PrefKey.USER_NAME, userName).commit();%0A        //commit() is sync%0A        //apply() is async%0A    %7D%0A%0A    public static String getPrefUserName(final Context context) %7B%0A        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);%0A        return sp.getString(PrefKey.USER_NAME, null);%0A    %7D%0A%0A    public static boolean isAppFirstLaunched(final Context context) %7B%0A        SharedPreferences sp = context.getSharedPreferences(PrefFile.SETTINGS, Context.MODE_PRIVATE);%0A        return sp.getBoolean(PrefKey.APP_FIRST_LAUNCH, true);%0A    %7D%0A%0A    public static void setAppFirstLaunched(final Context context, boolean value) %7B%0A        SharedPreferences sp = context.getSharedPreferences(PrefFile.SETTINGS, Context.MODE_PRIVATE);%0A        sp.edit().putBoolean(PrefKey.APP_FIRST_LAUNCH, value).apply();%0A    %7D%0A%7D%0A

add PrefUtils example