2011-11-08 60 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

相关问题