From 44e16031550929a5e840aa61dcb4246ff1f691d9 Mon Sep 17 00:00:00 2001 From: "yi.jang" Date: Thu, 11 Jul 2013 09:52:12 +0900 Subject: [PATCH] Use deleteDatabase method to improve safety of DB file handling Deleting .db files can make malformed database issues when WAL(write ahead logging) mode is enabled. EmailProvider doesn't use WAL mode currently, But it has to be fixed because it might cause the problem in the future. Change-Id: Ie0313c5d253f3080401b00b197e7cbf97f25423c Conflicts: src/com/android/email/provider/EmailProvider.java --- src/com/android/email/provider/EmailProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index fa340b733..e48326455 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -989,16 +989,16 @@ public class EmailProvider extends ContentProvider { mBodyDatabase = null; } // Look for orphans, and delete as necessary; these must always be in sync - File databaseFile = getContext().getDatabasePath(DATABASE_NAME); - File bodyFile = getContext().getDatabasePath(BODY_DATABASE_NAME); + final File databaseFile = getContext().getDatabasePath(DATABASE_NAME); + final File bodyFile = getContext().getDatabasePath(BODY_DATABASE_NAME); // TODO Make sure attachments are deleted if (databaseFile.exists() && !bodyFile.exists()) { LogUtils.w(TAG, "Deleting orphaned EmailProvider database..."); - databaseFile.delete(); + getContext().deleteDatabase(DATABASE_NAME); } else if (bodyFile.exists() && !databaseFile.exists()) { LogUtils.w(TAG, "Deleting orphaned EmailProviderBody database..."); - bodyFile.delete(); + getContext().deleteDatabase(BODY_DATABASE_NAME); } } @Override