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:
parent
5673236ebe
commit
44e1603155
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user