Fix SharedPrefsBackupHelper so it doesn't hard code the paths to the files.

This took quite a bit of refactoring.
This commit is contained in:
Joe Onorato
2009-06-10 17:07:15 -07:00
parent 0b77453076
commit 23ecae3bbb
12 changed files with 236 additions and 88 deletions

View File

@@ -300,10 +300,14 @@ class ApplicationContext extends Context {
return new File(prefsFile.getPath() + ".bak");
}
public File getSharedPrefsFile(String name) {
return makeFilename(getPreferencesDir(), name + ".xml");
}
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
SharedPreferencesImpl sp;
File f = makeFilename(getPreferencesDir(), name + ".xml");
File f = getSharedPrefsFile(name);
synchronized (sSharedPrefs) {
sp = sSharedPrefs.get(f);
if (sp != null && !sp.hasFileChanged()) {