+
+ // Get a cursor for the bookmarks table.
+ Cursor importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM " + BookmarksDatabaseHelper.BOOKMARKS_TABLE, null);
+
+ // Delete the current bookmarks database.
+ context.deleteDatabase(BookmarksDatabaseHelper.BOOKMARKS_DATABASE);
+
+ // Create a new bookmarks database. The `0` specifies the database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`.
+ BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(context, null, null, 0);
+
+ // Move to the first bookmark.
+ importBookmarksCursor.moveToFirst();
+
+ // Copy the data from the import bookmarks cursor into the bookmarks database.
+ for (int i = 0; i < importBookmarksCursor.getCount(); i++) {
+ // Extract the record from the cursor and store the data in a ContentValues.
+ ContentValues bookmarksContentValues = new ContentValues();
+ bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_NAME, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
+ bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_URL, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)));
+ bookmarksContentValues.put(BookmarksDatabaseHelper.PARENT_FOLDER, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER)));
+ bookmarksContentValues.put(BookmarksDatabaseHelper.DISPLAY_ORDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)));
+ bookmarksContentValues.put(BookmarksDatabaseHelper.IS_FOLDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)));
+ bookmarksContentValues.put(BookmarksDatabaseHelper.FAVORITE_ICON, importBookmarksCursor.getBlob(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON)));
+
+ // Insert the record into the export database.
+ bookmarksDatabaseHelper.createBookmark(bookmarksContentValues);
+
+ // Advance to the next record.
+ importBookmarksCursor.moveToNext();
+ }
+
+ // Close the bookmarks cursor.
+ importBookmarksCursor.close();
+
+ // Close the bookmarks database.
+ bookmarksDatabaseHelper.close();
+
+