diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2013-01-05 17:48:51 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2013-01-05 17:48:51 +0100 |
| commit | 33d99d09d8d06bb11c9496681ad82e07937be083 (patch) | |
| tree | 4235e8156c340fc31278e1f378c4a2887d300018 /main/src/cgeo/geocaching/files/LocalStorage.java | |
| parent | 6a4203528a0309ee0edb557e90571d4aeee9f2c1 (diff) | |
| parent | 52465e631ee1c469b66534c714d232b449362901 (diff) | |
| download | cgeo-33d99d09d8d06bb11c9496681ad82e07937be083.zip cgeo-33d99d09d8d06bb11c9496681ad82e07937be083.tar.gz cgeo-33d99d09d8d06bb11c9496681ad82e07937be083.tar.bz2 | |
Merge branch 'release' into upstream
Conflicts:
main/res/values/strings.xml
Diffstat (limited to 'main/src/cgeo/geocaching/files/LocalStorage.java')
| -rw-r--r-- | main/src/cgeo/geocaching/files/LocalStorage.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/files/LocalStorage.java b/main/src/cgeo/geocaching/files/LocalStorage.java index 4cf28f7..3101ae9 100644 --- a/main/src/cgeo/geocaching/files/LocalStorage.java +++ b/main/src/cgeo/geocaching/files/LocalStorage.java @@ -1,11 +1,11 @@ package cgeo.geocaching.files; +import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.utils.CryptUtils; import cgeo.geocaching.utils.Log; import ch.boye.httpclientandroidlib.Header; import ch.boye.httpclientandroidlib.HttpResponse; - import org.apache.commons.lang3.StringUtils; import android.os.Environment; @@ -30,6 +30,8 @@ public class LocalStorage { /** Name of the local private directory used to hold cached information */ public final static String cache = ".cgeo"; + private static File internalStorageBase; + /** * Return the primary storage cache root (external media if mounted, phone otherwise). * @@ -67,7 +69,11 @@ public class LocalStorage { } private static File getInternalStorageBase() { - return new File(new File(Environment.getDataDirectory(), "data"), "cgeo.geocaching"); + if (internalStorageBase == null) { + // A race condition will do no harm as the operation is idempotent. No need to synchronize. + internalStorageBase = cgeoapplication.getInstance().getApplicationContext().getFilesDir().getParentFile(); + } + return internalStorageBase; } /** |
