am 981a72a1: Merge "[don\'t auto-merge] Don\'t re-read SharedPreferences unnecessarily." into gingerbread
* commit '981a72a1506f7e6e42747b9aa0be2001795c6619': [don't auto-merge] Don't re-read SharedPreferences unnecessarily.
This commit is contained in:
@@ -364,7 +364,8 @@ class ContextImpl extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map map = null;
|
Map map = null;
|
||||||
if (prefsFile.exists() && prefsFile.canRead()) {
|
FileStatus stat = new FileStatus();
|
||||||
|
if (FileUtils.getFileStatus(prefsFile.getPath(), stat) && prefsFile.canRead()) {
|
||||||
try {
|
try {
|
||||||
FileInputStream str = new FileInputStream(prefsFile);
|
FileInputStream str = new FileInputStream(prefsFile);
|
||||||
map = XmlUtils.readMapXml(str);
|
map = XmlUtils.readMapXml(str);
|
||||||
@@ -377,7 +378,7 @@ class ContextImpl extends Context {
|
|||||||
Log.w(TAG, "getSharedPreferences", e);
|
Log.w(TAG, "getSharedPreferences", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sp.replace(map);
|
sp.replace(map, stat);
|
||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
@@ -2766,12 +2767,16 @@ class ContextImpl extends Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(Map newContents) {
|
/* package */ void replace(Map newContents, FileStatus stat) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
mLoaded = true;
|
mLoaded = true;
|
||||||
if (newContents != null) {
|
if (newContents != null) {
|
||||||
mMap = newContents;
|
mMap = newContents;
|
||||||
}
|
}
|
||||||
|
if (stat != null) {
|
||||||
|
mStatTimestamp = stat.mtime;
|
||||||
|
mStatSize = stat.size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user