X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FBookmarksDatabaseHelper.java;h=984402e826a077877b8117e0323d5a8e19a4b243;hp=a2af6451ccfbf2787f479667881a7a9d0d046071;hb=fbb7aef30a9417c42661a0f76b5836dcf6a40242;hpb=55169899d6454cd57e40d32a792735df51caee85 diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java index a2af6451..984402e8 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java @@ -410,6 +410,22 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper { return bookmarksDatabase.rawQuery(GET_BOOKMARKS, null); } + // Get a cursor with just database ID of bookmarks and folders in the specified folder. This is useful for deleting folders with bookmarks that have favorite icons too large to fit in a cursor. + public Cursor getBookmarkIDs(String folderName) { + // Get a readable database handle. + SQLiteDatabase bookmarksDatabase = this.getReadableDatabase(); + + // SQL escape the folder name. + folderName = DatabaseUtils.sqlEscapeString(folderName); + + // Get everything in the bookmarks table with `folderName` as the `PARENT_FOLDER`. + String GET_BOOKMARKS = "SELECT " + _ID + " FROM " + BOOKMARKS_TABLE + + " WHERE " + PARENT_FOLDER + " = " + folderName; + + // Return the result as a cursor. The cursor cannot be closed because it is used in the parent activity. + return bookmarksDatabase.rawQuery(GET_BOOKMARKS, null); + } + // Get a cursor for bookmarks and folders in the specified folder except for ta specific list of IDs. public Cursor getBookmarksExcept(long[] exceptIdLongArray, String folderName) { // Get a readable database handle. @@ -477,7 +493,7 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper { SQLiteDatabase bookmarksDatabase = this.getReadableDatabase(); // Prepare the SQL statement to determine if `databaseId` is a folder. - String CHECK_IF_FOLDER = "SELECT * FROM " + BOOKMARKS_TABLE + + String CHECK_IF_FOLDER = "SELECT " + IS_FOLDER + " FROM " + BOOKMARKS_TABLE + " WHERE " + _ID + " = " + databaseId; // Populate the folder cursor.