diff options
| author | Grace Kloba <klobag@google.com> | 2009-10-13 12:57:08 -0700 |
|---|---|---|
| committer | Grace Kloba <klobag@google.com> | 2009-10-13 12:57:08 -0700 |
| commit | 58def690a87b4aa2c01331c06b61e457198de0ea (patch) | |
| tree | 5b338439f7a2dbaaf99dcd7bb4aeb426eb1654e7 | |
| parent | d34f3994da32d0fcf5f6d6824d123d51c02c988e (diff) | |
| download | frameworks_base-58def690a87b4aa2c01331c06b61e457198de0ea.zip frameworks_base-58def690a87b4aa2c01331c06b61e457198de0ea.tar.gz frameworks_base-58def690a87b4aa2c01331c06b61e457198de0ea.tar.bz2 | |
If openOrCreateDatabase() throws an exception, delete
the old db and re-do it. If it still fails, something
bad happens, like the directory may have the different
permission. Let it throw as WebView needs the db.
Fix http://b/issue?id=2179339
| -rw-r--r-- | core/java/android/webkit/WebViewDatabase.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java index 6e10811..110e4f8 100644 --- a/core/java/android/webkit/WebViewDatabase.java +++ b/core/java/android/webkit/WebViewDatabase.java @@ -27,6 +27,7 @@ import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteStatement; import android.util.Log; import android.webkit.CookieManager.Cookie; @@ -174,7 +175,16 @@ public class WebViewDatabase { public static synchronized WebViewDatabase getInstance(Context context) { if (mInstance == null) { mInstance = new WebViewDatabase(); - mDatabase = context.openOrCreateDatabase(DATABASE_FILE, 0, null); + try { + mDatabase = context + .openOrCreateDatabase(DATABASE_FILE, 0, null); + } catch (SQLiteException e) { + // try again by deleting the old db and create a new one + if (context.deleteDatabase(DATABASE_FILE)) { + mDatabase = context.openOrCreateDatabase(DATABASE_FILE, 0, + null); + } + } // mDatabase should not be null, // the only case is RequestAPI test has problem to create db @@ -194,8 +204,16 @@ public class WebViewDatabase { mDatabase.setLockingEnabled(false); } - mCacheDatabase = context.openOrCreateDatabase(CACHE_DATABASE_FILE, - 0, null); + try { + mCacheDatabase = context.openOrCreateDatabase( + CACHE_DATABASE_FILE, 0, null); + } catch (SQLiteException e) { + // try again by deleting the old db and create a new one + if (context.deleteDatabase(CACHE_DATABASE_FILE)) { + mCacheDatabase = context.openOrCreateDatabase( + CACHE_DATABASE_FILE, 0, null); + } + } // mCacheDatabase should not be null, // the only case is RequestAPI test has problem to create db |
