SharedPreferences的缓存值是否有意义?

Tob*_*ias 10 performance android preferences

在我当前的Android应用程序中,我有几个存储在SharedPreferences中的设置和一个处理它们访问权限的对象.我现在想知道缓存这些值是否有意义,或者是否更多地访问它们,如:

public final boolean isxxxEnabled() {
    return preferences.getBoolean("xxx", false);
}
Run Code Online (Sandbox Code Playgroud)

代替

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 
}
Run Code Online (Sandbox Code Playgroud)

Kur*_*aum 5

缓存共享首选项实际上不是必需的。您获得的速度充其量只是微不足道的,它将增加您必须编写的代码。我说不要打扰。