public class SharedPreferencesUtils {

    
    public static void put(String key ,String value,Context context){
        SharedPreferences sp = initSharedPreferences(context);
        SharedPreferences.Editor editor = sp.edit();   
        editor.putString(key, String.valueOf(value));   
        editor.commit();   
    }
    
    
    public static String get(String value,Context context){
        SharedPreferences sp = initSharedPreferences(context);
        String result = sp.getString(value, "");
        return result;
    }
    

    public static SharedPreferences initSharedPreferences(Context context){
        return context.getSharedPreferences("LOLLOOK", Context.MODE_PRIVATE);
    }
}

 

 

posted on 2014-05-05 10:27  青年程序猿  阅读(304)  评论(0)    收藏  举报