diff options
author | Ben Murdoch <benm@google.com> | 2011-07-28 11:24:15 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-28 11:24:15 -0700 |
commit | d92922c4011b22f82ca0f69437169cf4599c51e3 (patch) | |
tree | f96023f3ef7c8eca21ae59c90abf51141d95735c /src/com/android/browser/provider | |
parent | fc49252cdafd9c358b9b15fb0dcb973f09c8eb07 (diff) | |
parent | b98cb5187fcb3034ee3675de791fd811d76d1593 (diff) | |
download | packages_apps_Browser-d92922c4011b22f82ca0f69437169cf4599c51e3.zip packages_apps_Browser-d92922c4011b22f82ca0f69437169cf4599c51e3.tar.gz packages_apps_Browser-d92922c4011b22f82ca0f69437169cf4599c51e3.tar.bz2 |
Merge "Fix Strict Mode violation in SnapshotProvider."
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r-- | src/com/android/browser/provider/SnapshotProvider.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/android/browser/provider/SnapshotProvider.java b/src/com/android/browser/provider/SnapshotProvider.java index 49557f7..c0aad23 100644 --- a/src/com/android/browser/provider/SnapshotProvider.java +++ b/src/com/android/browser/provider/SnapshotProvider.java @@ -106,7 +106,6 @@ public class SnapshotProvider extends ContentProvider { @Override public boolean onCreate() { - mOpenHelper = new SnapshotDatabaseHelper(getContext()); IntentFilter filter = new IntentFilter(Intent.ACTION_MEDIA_EJECT); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); getContext().registerReceiver(mExternalStorageReceiver, filter); @@ -117,13 +116,15 @@ public class SnapshotProvider extends ContentProvider { @Override public void onReceive(Context context, Intent intent) { - try { - mOpenHelper.close(); - } catch (Throwable t) { - // We failed to close the open helper, which most likely means - // another thread is busy attempting to open the database - // or use the database. Let that thread try to gracefully - // deal with the error + if (mOpenHelper != null) { + try { + mOpenHelper.close(); + } catch (Throwable t) { + // We failed to close the open helper, which most likely means + // another thread is busy attempting to open the database + // or use the database. Let that thread try to gracefully + // deal with the error + } } } }; @@ -132,6 +133,9 @@ public class SnapshotProvider extends ContentProvider { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { try { + if (mOpenHelper == null) { + mOpenHelper = new SnapshotDatabaseHelper(getContext()); + } return mOpenHelper.getWritableDatabase(); } catch (Throwable t) { return null; @@ -145,6 +149,9 @@ public class SnapshotProvider extends ContentProvider { if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { try { + if (mOpenHelper == null) { + mOpenHelper = new SnapshotDatabaseHelper(getContext()); + } return mOpenHelper.getReadableDatabase(); } catch (Throwable t) { return null; |