diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2013-01-05 17:41:20 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2013-01-05 17:45:49 +0100 |
| commit | f846c24ba99b68f73387f9cff0615cb9a9f7abc8 (patch) | |
| tree | ef6a21136515ca582fe4c0401e9bc44eee554302 | |
| parent | 76e05aac4eee4d5cd02c3905dd47b9415618d008 (diff) | |
| download | cgeo-f846c24ba99b68f73387f9cff0615cb9a9f7abc8.zip cgeo-f846c24ba99b68f73387f9cff0615cb9a9f7abc8.tar.gz cgeo-f846c24ba99b68f73387f9cff0615cb9a9f7abc8.tar.bz2 | |
fix #2336: support for secondary users in multi-users mode
This will allow c:geo to work correctly in multi-users mode as long as
the default settings (keep files on internal sd card or phone memory)
are used.
Files stored on secondary memory will still be shared between users,
but the permissions should be allowing that.
| -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 da0f981..c392564 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; } /** |
