diff --git a/src/com/fsck/k9/mail/store/LockableDatabase.java b/src/com/fsck/k9/mail/store/LockableDatabase.java index 67090aace..9ce72fe2b 100644 --- a/src/com/fsck/k9/mail/store/LockableDatabase.java +++ b/src/com/fsck/k9/mail/store/LockableDatabase.java @@ -5,10 +5,12 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import android.annotation.TargetApi; import android.app.Application; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; +import android.os.Build; import android.util.Log; import com.fsck.k9.K9; @@ -479,7 +481,7 @@ public class LockableDatabase { } catch (Exception e) { } try { - storageManager.getDatabase(uUid, mStorageProviderId).delete(); + deleteDatabase(storageManager.getDatabase(uUid, mStorageProviderId)); } catch (Exception e) { Log.i(K9.LOG_TAG, "LockableDatabase: delete(): Unable to delete backing DB file", e); } @@ -495,4 +497,18 @@ public class LockableDatabase { } } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void deleteDatabase(File database) { + boolean deleted = false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + deleted = SQLiteDatabase.deleteDatabase(database); + } else { + deleted = database.delete(); + deleted |= new File(database.getPath() + "-journal").delete(); + } + if (!deleted) { + Log.i(K9.LOG_TAG, + "LockableDatabase: deleteDatabase(): No files deleted."); + } + } }