package com.optimalorange.cooltechnologies.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by WANGZHENGZE on 2014/11/20.
 */
public class Utils {

    /**
     * 将string存入SharedPreferences
     *
     * @param context context
     * @param key     key
     * @param value   value
     */
    public static void saveString(Context context, String key, String value) {
        SharedPreferences.Editor editor =
                PreferenceManager.getDefaultSharedPreferences(context).edit();
        editor.putString(key, value);
        editor.commit();
    }

    /**
     * 从SharedPreferences中取出string
     *
     * @param context  context
     * @param key      key
     * @param defValue defValue
     * @return string
     */
    public static String getString(Context context, String key, String defValue) {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(context);
        return sharedPreferences.getString(key, defValue);
    }
}

@@ -163,16 +163,62 @@
 nager;%0A%0A
+import com.optimalorange.cooltechnologies.R;%0A%0A
 /**%0A * C
@@ -496,32 +496,25 @@
 ng value) %7B%0A
-        
+%09
 SharedPrefer
@@ -535,32 +535,18 @@
 ditor =%0A
-                
+%09%09
 Preferen
@@ -600,24 +600,17 @@
 edit();%0A
-        
+%09
 editor.p
@@ -631,24 +631,17 @@
 value);%0A
-        
+%09
 editor.c
@@ -909,24 +909,17 @@
 alue) %7B%0A
-        
+%09
 SharedPr
@@ -952,24 +952,10 @@
 s =%0A
-                
+%09%09
 Pref
@@ -1010,16 +1010,9 @@
 t);%0A
-        
+%09
 retu
@@ -1063,11 +1063,454 @@
 );%0A    %7D
+%0A%0A    /**%0A     * %E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E6%97%B6%E9%95%BF%EF%BC%88%E7%A7%92%EF%BC%89%E8%BD%AC%E6%8D%A2%E4%B8%BA%EF%BC%88yy-mm-ss)%0A     *%0A     * @param duration int%0A     * @return String%0A     */%0A    public static String getDurationString(int duration) %7B%0A%09int hours = (duration / (60 * 60));%0A%09int minutes = (duration - hours * (60 * 60)) / 60;%0A%09int seconds = duration - hours * (60 * 60) - minutes * 60;%0A%09if (hours == 0) %7B%0A%09    return minutes + %22 : %22 + seconds;%0A%09%7D else %7B%0A%09    return hours + %22 : %22 + minutes + %22 : %22 + seconds;%0A%09%7D%0A    %7D
 %0A%7D%0A

修改Utils.java 增加getDurationString方法