+ public Cursor getFoldersCursorExcept(String exceptFolders) {
+ // Get a readable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
+
+ // Prepare the SQL statement to get the `Cursor` for the folders.
+ final String GET_FOLDERS_EXCEPT = "Select * FROM " + BOOKMARKS_TABLE +
+ " WHERE " + IS_FOLDER + " = " + 1 +
+ " AND " + BOOKMARK_NAME + " NOT IN (" + exceptFolders +
+ ") ORDER BY " + BOOKMARK_NAME + " ASC";
+
+ // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`.
+ // We can't close the `Cursor` because we need to use it in the parent activity.
+ return bookmarksDatabase.rawQuery(GET_FOLDERS_EXCEPT, null);
+ }
+
+ public Cursor getSubfoldersCursor(String currentFolder) {
+ // Get a readable database handle.
+ SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
+
+ // SQL escape `currentFolder.
+ currentFolder = DatabaseUtils.sqlEscapeString(currentFolder);
+
+ // Prepare the SQL statement to get the `Cursor` for the subfolders.
+ final String GET_SUBFOLDERS = "Select * FROM " + BOOKMARKS_TABLE +
+ " WHERE " + PARENT_FOLDER + " = " + currentFolder +
+ " AND " + IS_FOLDER + " = " + 1;
+
+ // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`.
+ // We can't close the `Cursor` because we need to use it in the parent activity.
+ return bookmarksDatabase.rawQuery(GET_SUBFOLDERS, null);
+ }
+