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
This commit is contained in:
yi.jang 2013-07-11 09:52:12 +09:00 committed by Paul Westbrook
parent 5673236ebe
commit 44e1603155

View File

@ -989,16 +989,16 @@ public class EmailProvider extends ContentProvider {
mBodyDatabase = null; mBodyDatabase = null;
} }
// Look for orphans, and delete as necessary; these must always be in sync // Look for orphans, and delete as necessary; these must always be in sync
File databaseFile = getContext().getDatabasePath(DATABASE_NAME); final File databaseFile = getContext().getDatabasePath(DATABASE_NAME);
File bodyFile = getContext().getDatabasePath(BODY_DATABASE_NAME); final File bodyFile = getContext().getDatabasePath(BODY_DATABASE_NAME);
// TODO Make sure attachments are deleted // TODO Make sure attachments are deleted
if (databaseFile.exists() && !bodyFile.exists()) { if (databaseFile.exists() && !bodyFile.exists()) {
LogUtils.w(TAG, "Deleting orphaned EmailProvider database..."); LogUtils.w(TAG, "Deleting orphaned EmailProvider database...");
databaseFile.delete(); getContext().deleteDatabase(DATABASE_NAME);
} else if (bodyFile.exists() && !databaseFile.exists()) { } else if (bodyFile.exists() && !databaseFile.exists()) {
LogUtils.w(TAG, "Deleting orphaned EmailProviderBody database..."); LogUtils.w(TAG, "Deleting orphaned EmailProviderBody database...");
bodyFile.delete(); getContext().deleteDatabase(BODY_DATABASE_NAME);
} }
} }
@Override @Override