diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-01-24 13:20:57 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2014-01-24 13:20:57 -0800 |
commit | fce5890a11b421532568d9838ae3dd5836acead8 (patch) | |
tree | c4b90136cdad95890e656543330d55021bc6adbc /core/java/android/database | |
parent | 8aca9e335f9b2eb060878b2e6cbe241928d83dc9 (diff) | |
download | frameworks_base-fce5890a11b421532568d9838ae3dd5836acead8.zip frameworks_base-fce5890a11b421532568d9838ae3dd5836acead8.tar.gz frameworks_base-fce5890a11b421532568d9838ae3dd5836acead8.tar.bz2 |
Fix NPE in deleteDatabase().
If the directory containing the database does not exist then
listFiles() will return null. Tolerate this situation instead
of crashing.
Bug: 12600784
Change-Id: I5d83a867a5e8478f50887e5798b42c5f6859b77c
Diffstat (limited to 'core/java/android/database')
-rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 60ccc61..433d5d1 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -738,14 +738,16 @@ public final class SQLiteDatabase extends SQLiteClosable { File dir = file.getParentFile(); if (dir != null) { final String prefix = file.getName() + "-mj"; - final FileFilter filter = new FileFilter() { + File[] files = dir.listFiles(new FileFilter() { @Override public boolean accept(File candidate) { return candidate.getName().startsWith(prefix); } - }; - for (File masterJournal : dir.listFiles(filter)) { - deleted |= masterJournal.delete(); + }); + if (files != null) { + for (File masterJournal : files) { + deleted |= masterJournal.delete(); + } } } return deleted; |