我有一個簡單的問題,我有以下功能,並有它的參數,叫cacheTime
,我應該如何設置它爲4小時,我應該將它設置爲4 * 3600000
?currentTimeMillis 4小時
public static File getCache(String name, Context c, int cacheTime)
{
if (cacheTime <= 0)
return null;
File cache = new File(c.getCacheDir(), name);
long now = System.currentTimeMillis();
if (cache.exists() && (now - cache.lastModified() < cacheTime))
return cache;
return null;
}
4 * 3600000.這是毫秒,而不是秒。 – 323go 2013-02-15 21:47:52
@ 323go謝謝,編輯。 – NullPointer 2013-02-18 15:46:21