]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/helpers/BookmarksDatabaseHelper.java
Hide the move to folder menu item if no folders exist. https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / helpers / BookmarksDatabaseHelper.java
index a743010c485422ed2c8659d6ac919cfd48c512fd..55cc346bd7e73f09790638df6cd071e3fe104518 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -216,6 +216,19 @@ public class BookmarksDatabaseHelper extends SQLiteOpenHelper {
         return parentFolder;
     }
 
+    public Cursor getAllFoldersCursor() {
+        // Get a readable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
+
+        // 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;
+
+        // 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_FOLDERS, null);
+    }
+
     public Cursor getAllBookmarksCursor() {
         // Get a readable database handle.
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();