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=532c771d51e4c93d0b82ff6d6cc363e5b337f827;hp=84481518e508fe477b9774ac39c156763bca3689;hb=e12908eb00d9c54c0a3c9f56312a31b9e5dfd094;hpb=a8669fa252bd4a278decc411912d6f8674ff483d 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 84481518..532c771d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java @@ -231,7 +231,8 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper { // Prepare the SQL statement to get the `Cursor` for all the folders. final String GET_ALL_FOLDERS = "SELECT * FROM " + BOOKMARKS_TABLE + - " WHERE " + IS_FOLDER + " = " + 1; + " WHERE " + IS_FOLDER + " = " + 1 + + " 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. @@ -251,6 +252,22 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper { return bookmarksDatabase.rawQuery(GET_ALL_BOOKMARKS, null); } + // Get a `Cursor` for all bookmarks and folders in the specified folder. + public Cursor getAllBookmarksCursor(String folderName) { + // Get a readable database handle. + SQLiteDatabase bookmarksDatabase = this.getReadableDatabase(); + + // SQL escape `folderName`. + folderName = DatabaseUtils.sqlEscapeString(folderName); + + // Get everything in the `BOOKMARKS_TABLE` with `folderName` as the `PARENT_FOLDER`. + final String GET_ALL_BOOKMARKS = "SELECT * FROM " + BOOKMARKS_TABLE + + " WHERE " + PARENT_FOLDER + " = " + folderName; + + // 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_ALL_BOOKMARKS, null); + } + // Get a `Cursor` for all bookmarks and folders in the specified folder ordered by display order. public Cursor getAllBookmarksCursorByDisplayOrder(String folderName) { // Get a readable database handle.