summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/BrowserProvider.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-02-23 14:28:51 -0500
committerLeon Scroggins <scroggo@google.com>2010-02-23 14:38:53 -0500
commitf2463ae7ea9f59f3408a87b146d83bee4f26c37b (patch)
tree3ef4c57304683861d69442d4fed7ed10c60c7585 /src/com/android/browser/BrowserProvider.java
parentab1655e799a3b0a82cea62e05b4017c21ab53881 (diff)
downloadpackages_apps_browser-f2463ae7ea9f59f3408a87b146d83bee4f26c37b.zip
packages_apps_browser-f2463ae7ea9f59f3408a87b146d83bee4f26c37b.tar.gz
packages_apps_browser-f2463ae7ea9f59f3408a87b146d83bee4f26c37b.tar.bz2
Backup bookmarks when a new bookmark is added.
Fix for http://b/issue?id=2332942
Diffstat (limited to 'src/com/android/browser/BrowserProvider.java')
-rw-r--r--src/com/android/browser/BrowserProvider.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index dda5765..ca24b49 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -1056,18 +1056,14 @@ public class BrowserProvider extends ContentProvider {
throw new IllegalArgumentException("Unknown URL");
}
- String id = null;
- boolean isBookmarkTable = (match == URI_MATCH_BOOKMARKS_ID);
- boolean changingBookmarks = false;
-
- if (isBookmarkTable || match == URI_MATCH_SEARCHES_ID) {
+ if (match == URI_MATCH_BOOKMARKS_ID || match == URI_MATCH_SEARCHES_ID) {
StringBuilder sb = new StringBuilder();
if (where != null && where.length() > 0) {
sb.append("( ");
sb.append(where);
sb.append(" ) AND ");
}
- id = url.getPathSegments().get(1);
+ String id = url.getPathSegments().get(1);
sb.append("_id = ");
sb.append(id);
where = sb.toString();
@@ -1078,23 +1074,23 @@ public class BrowserProvider extends ContentProvider {
// Not all bookmark-table updates should be backed up. Look to see
// whether we changed the title, url, or "is a bookmark" state, and
// request a backup if so.
- if (isBookmarkTable) {
+ if (match == URI_MATCH_BOOKMARKS_ID || match == URI_MATCH_BOOKMARKS) {
+ boolean changingBookmarks = false;
// Alterations to the bookmark field inherently change the bookmark
// set, so we don't need to query the record; we know a priori that
// we will need to back up this change.
if (values.containsKey(BookmarkColumns.BOOKMARK)) {
changingBookmarks = true;
- }
- // changing the title or URL of a bookmark record requires a backup,
- // but we don't know wether such an update is on a bookmark without
- // querying the record
- if (!changingBookmarks &&
- (values.containsKey(BookmarkColumns.TITLE)
- || values.containsKey(BookmarkColumns.URL))) {
- // when isBookmarkTable is true, the 'id' var was assigned above
+ } else if ((values.containsKey(BookmarkColumns.TITLE)
+ || values.containsKey(BookmarkColumns.URL))
+ && values.containsKey(BookmarkColumns._ID)) {
+ // If a title or URL has been changed, check to see if it is to
+ // a bookmark. The ID should have been included in the update,
+ // so use it.
Cursor cursor = cr.query(Browser.BOOKMARKS_URI,
new String[] { BookmarkColumns.BOOKMARK },
- "_id = " + id, null, null);
+ BookmarkColumns._ID + " = "
+ + values.getAsString(BookmarkColumns._ID), null, null);
if (cursor.moveToNext()) {
changingBookmarks = (cursor.getInt(0) != 0);
}