From 321fbe614d58862a03c40b767078c86b0ff96126 Mon Sep 17 00:00:00 2001 From: ashley willis Date: Tue, 8 May 2012 18:29:23 -0500 Subject: [PATCH] use the new way on internal storage, or the original way otherwise --- src/com/fsck/k9/mail/store/LockableDatabase.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LockableDatabase.java b/src/com/fsck/k9/mail/store/LockableDatabase.java index 5d2542473..b303c2aef 100644 --- a/src/com/fsck/k9/mail/store/LockableDatabase.java +++ b/src/com/fsck/k9/mail/store/LockableDatabase.java @@ -371,12 +371,24 @@ public class LockableDatabase { try { final File databaseFile = prepareStorage(mStorageProviderId); try { - mDb = application.openOrCreateDatabase(databaseFile.getName(), Context.MODE_PRIVATE, null); + if (StorageManager.InternalStorageProvider.ID.equals(mStorageProviderId)) { + // internal storage + mDb = application.openOrCreateDatabase(databaseFile.getName(), Context.MODE_PRIVATE, null); + } else { + // external storage + mDb = SQLiteDatabase.openOrCreateDatabase(databaseFile, null); + } } catch (SQLiteException e) { // try to gracefully handle DB corruption - see issue 2537 Log.w(K9.LOG_TAG, "Unable to open DB " + databaseFile + " - removing file and retrying", e); databaseFile.delete(); - mDb = application.openOrCreateDatabase(databaseFile.getName(), Context.MODE_PRIVATE, null); + if (StorageManager.InternalStorageProvider.ID.equals(mStorageProviderId)) { + // internal storage + mDb = application.openOrCreateDatabase(databaseFile.getName(), Context.MODE_PRIVATE, null); + } else { + // external storage + mDb = SQLiteDatabase.openOrCreateDatabase(databaseFile, null); + } } if (mDb.getVersion() != mSchemaDefinition.getVersion()) { mSchemaDefinition.doDbUpgrade(mDb);