2011-11-08 105 views
9

在我當前的Android應用程序中,我有幾個存儲在SharedPreferences中的設置和一個處理對它們的訪問的對象。我現在不知道是否是有意義的緩存值,或者如果沒有母校多少訪問他們喜歡:中SharedPreferences的緩存值是否有意義?

public final boolean isxxxEnabled() { 
    return preferences.getBoolean("xxx", false); 
} 

代替

public final boolean isxxxEnabled() { 
      // check if value changed 
      // if not, check if value is cached 
      // decide whether to return cached or new 
      // cache value 
    return 
} 

回答

4

緩存共享偏好是不是真的有必要。你得到的速度最多隻能是邊際,它會增加你必須編寫的代碼。我會說不要打擾。

+0

你有這方面的消息嗎? – EmmanuelMess

+0

好的,[這裏](https://stackoverflow.com/a/34684174/3124150)是一個參考。 – EmmanuelMess

相關問題