0
我可以得到文件的最後修改日期和時間,我想比較它與我的上次修改日期和時間偏好,但不幸的是它總是如此。我犯了一個錯誤?比較長日期格式從偏好
/* Get Last Update Time from Preferences */
SharedPreferences prefs1 = getPreferences(0);
long lastUpdateTime = prefs1.getLong("lastUpdateTime", 0);
File file = new File(filePath);
Date lastModDate = new Date(file.lastModified());
long curMillis = lastModDate.getTime();
/* Should Activity Check for Updates Now? */
if ((lastUpdateTime) <= curMillis) {
/* Save current timestamp for next Check */
SharedPreferences.Editor editor = getPreferences(0).edit();
editor.putLong("lastUpdateTime", curMillis);
editor.commit();
do somthing....
}
你是對的,它的工作感謝隊友.. – Riz