+ return isFolder;
+ }
+
+ public void updateBookmark(int databaseId, String bookmarkName, String bookmarkUrl) {
+ // Store the updated values in `bookmarkContentValues`.
+ ContentValues bookmarkContentValues = new ContentValues();
+
+ bookmarkContentValues.put(BOOKMARK_NAME, bookmarkName);
+ bookmarkContentValues.put(BOOKMARK_URL, bookmarkUrl);
+
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Update the bookmark. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();
+ }
+
+ public void updateBookmark(int databaseId, String bookmarkName, String bookmarkUrl, byte[] favoriteIcon) {
+ // Store the updated values in `bookmarkContentValues`.
+ ContentValues bookmarkContentValues = new ContentValues();
+
+ bookmarkContentValues.put(BOOKMARK_NAME, bookmarkName);
+ bookmarkContentValues.put(BOOKMARK_URL, bookmarkUrl);
+ bookmarkContentValues.put(FAVORITE_ICON, favoriteIcon);
+
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Update the bookmark. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();
+ }
+
+ public void updateFolder(int databaseId, String oldFolderName, String newFolderName) {
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Update the folder first. Store the updated values in `folderContentValues`.
+ ContentValues folderContentValues = new ContentValues();
+
+ folderContentValues.put(BOOKMARK_NAME, newFolderName);
+
+ // Run the update on the folder. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, folderContentValues, _ID + " = " + databaseId, null);
+
+
+ // Update the bookmarks inside the folder with the new parent folder name.
+ ContentValues bookmarkContentValues = new ContentValues();
+
+ bookmarkContentValues.put(PARENT_FOLDER, newFolderName);
+
+ // SQL escape `oldFolderName`.
+ oldFolderName = DatabaseUtils.sqlEscapeString(oldFolderName);
+
+ // Run the update on the bookmarks. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, PARENT_FOLDER + " = " + oldFolderName, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();
+ }
+
+ public void updateFolder(int databaseId, String oldFolderName, String newFolderName, byte[] folderIcon) {
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Update the folder first. Store the updated values in `folderContentValues`.
+ ContentValues folderContentValues = new ContentValues();
+
+ folderContentValues.put(BOOKMARK_NAME, newFolderName);
+ folderContentValues.put(FAVORITE_ICON, folderIcon);
+
+ // Run the update on the folder. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, folderContentValues, _ID + " = " + databaseId, null);
+
+
+ // Update the bookmarks inside the folder with the new parent folder name.
+ ContentValues bookmarkContentValues = new ContentValues();
+
+ bookmarkContentValues.put(PARENT_FOLDER, newFolderName);
+
+ // SQL escape `oldFolderName`.
+ oldFolderName = DatabaseUtils.sqlEscapeString(oldFolderName);
+
+ // Run the update on the bookmarks. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, PARENT_FOLDER + " = " + oldFolderName, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();
+ }
+
+ public void updateBookmarkDisplayOrder(int databaseId, int displayOrder) {
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Store the new display order in `bookmarkContentValues`.
+ ContentValues bookmarkContentValues = new ContentValues();
+ bookmarkContentValues.put(DISPLAY_ORDER, displayOrder);
+
+ // Update the database. The last argument is `null` because there are no `whereArgs`.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();
+ }
+
+ public void moveToFolder(int databaseId, String newFolder) {
+ // Get a writable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+ // Get the highest `DISPLAY_ORDER` in the new folder
+ String newFolderSqlEscaped = DatabaseUtils.sqlEscapeString(newFolder);
+ final String NEW_FOLDER = "Select * FROM " + BOOKMARKS_TABLE +
+ " WHERE " + PARENT_FOLDER + " = " + newFolderSqlEscaped +
+ " ORDER BY " + DISPLAY_ORDER + " ASC";
+ // The second argument is `null` because there are no `selectionArgs`.
+ Cursor newFolderCursor = bookmarksDatabase.rawQuery(NEW_FOLDER, null);
+ int displayOrder;
+ if (newFolderCursor.getCount() > 0) {
+ newFolderCursor.moveToLast();
+ displayOrder = newFolderCursor.getInt(newFolderCursor.getColumnIndex(DISPLAY_ORDER)) + 1;
+ } else {
+ displayOrder = 0;
+ }
+ newFolderCursor.close();
+
+ // Store the new values in `bookmarkContentValues`.
+ ContentValues bookmarkContentValues = new ContentValues();
+ bookmarkContentValues.put(DISPLAY_ORDER, displayOrder);
+ bookmarkContentValues.put(PARENT_FOLDER, newFolder);
+
+ // Update the database. The last argument is 'null' because there are no 'whereArgs'.
+ bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
+
+ // Close the database handle.
+ bookmarksDatabase.close();