From f846c24ba99b68f73387f9cff0615cb9a9f7abc8 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 5 Jan 2013 17:41:20 +0100 Subject: 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. --- main/src/cgeo/geocaching/files/LocalStorage.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'main/src/cgeo/geocaching/files/LocalStorage.java') 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; } /** -- cgit v1.1