1 public class SharePrefersUtils { 2 private static final String name="cogi"; 3 public static boolean getboolean(Context con,String key,boolean defaultValues){ 4 SharedPreferences sp=con.getSharedPreferences(name 5 ,Context.MODE_PRIVATE); 6 return sp.getBoolean(key, defaultValues); 7 } 8 9 public static void putboolean(Context con,String key,boolean values){ 10 SharedPreferences sp=con.getSharedPreferences(name,Context.MODE_PRIVATE); 11 sp.edit().putBoolean(key, values).commit(); 12 } 13 14 public static String getstring(Context con,String key,String defaultValues){ 15 SharedPreferences sp=con.getSharedPreferences(name 16 ,Context.MODE_PRIVATE); 17 return sp.getString(key, defaultValues); 18 } 19 20 public static void setstring(Context con,String key,String values){ 21 SharedPreferences sp=con.getSharedPreferences(name,Context.MODE_PRIVATE); 22 sp.edit().putString(key, values).commit(); 23 } 24 25 26 }