summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/browser/BrowserActivity.java63
1 files changed, 34 insertions, 29 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 6271e24..0a3fec9 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2273,36 +2273,41 @@ public class BrowserActivity extends Activity
StringBuilder sb = new StringBuilder(
Browser.BookmarkColumns.URL + " = ");
DatabaseUtils.appendEscapedSQLString(sb, url);
- Cursor c = mResolver.query(Browser.BOOKMARKS_URI,
- Browser.HISTORY_PROJECTION,
- sb.toString(),
- null,
- null);
- if (c.moveToFirst()) {
- // The site has been visited before, so grab the
- // info from the database.
- Bitmap favicon = null;
- Bitmap thumbnail = null;
- String linkTitle = c.getString(Browser.
- HISTORY_PROJECTION_TITLE_INDEX);
- byte[] data = c.getBlob(Browser.
- HISTORY_PROJECTION_FAVICON_INDEX);
- if (data != null) {
- favicon = BitmapFactory.decodeByteArray(
- data, 0, data.length);
+ Cursor c = null;
+ try {
+ c = mResolver.query(Browser.BOOKMARKS_URI,
+ Browser.HISTORY_PROJECTION,
+ sb.toString(),
+ null,
+ null);
+ if (c.moveToFirst()) {
+ // The site has been visited before, so grab the
+ // info from the database.
+ Bitmap favicon = null;
+ Bitmap thumbnail = null;
+ String linkTitle = c.getString(Browser.
+ HISTORY_PROJECTION_TITLE_INDEX);
+ byte[] data = c.getBlob(Browser.
+ HISTORY_PROJECTION_FAVICON_INDEX);
+ if (data != null) {
+ favicon = BitmapFactory.decodeByteArray(
+ data, 0, data.length);
+ }
+ data = c.getBlob(Browser.
+ HISTORY_PROJECTION_THUMBNAIL_INDEX);
+ if (data != null) {
+ thumbnail = BitmapFactory.decodeByteArray(
+ data, 0, data.length);
+ }
+ sharePage(BrowserActivity.this,
+ linkTitle, url, favicon, thumbnail);
+ } else {
+ Browser.sendString(BrowserActivity.this, url,
+ getString(
+ R.string.choosertitle_sharevia));
}
- data = c.getBlob(Browser.
- HISTORY_PROJECTION_THUMBNAIL_INDEX);
- if (data != null) {
- thumbnail = BitmapFactory.decodeByteArray(
- data, 0, data.length);
- }
- sharePage(BrowserActivity.this,
- linkTitle, url, favicon, thumbnail);
- } else {
- Browser.sendString(BrowserActivity.this, url,
- getString(
- R.string.choosertitle_sharevia));
+ } finally {
+ if (c != null) c.close();
}
// close the cursor after its used
if (c != null) {