Bug 1234315 - Implement getBookmarkIdForFolderWithParentAndName draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 24 Feb 2016 14:27:06 -0800
changeset 336559 51c1e4ff90fccbf4c277eedfa3155479c57a24ca
parent 336558 a813275621463f55e0cc3d726969a53e6762a4c8
child 336560 1c54cf74e74dd591e63cffcd326c6a4533910908
child 337471 0f1f7c1e38779ab5d2cb01c440c617608c0e7e4e
push id12121
push userahunt@mozilla.com
push dateThu, 03 Mar 2016 19:16:47 +0000
bugs1234315
milestone47.0a1
Bug 1234315 - Implement getBookmarkIdForFolderWithParentAndName MozReview-Commit-ID: C73LJ1viAHP
mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
@@ -1221,16 +1221,38 @@ public final class BrowserDatabaseHelper
     }
 
     protected static void debug(String message) {
         if (logDebug) {
             Log.d(LOGTAG, message);
         }
     }
 
+    private Integer getBookmarkIdForFolderWithParentAndName(SQLiteDatabase db,
+                                                            final int parentId,
+                                                            final String folderName) {
+        Integer id = null;
+
+        final Cursor c = db.query(TABLE_BOOKMARKS,
+                                         new String[] { Bookmarks._ID },
+                                         Bookmarks.PARENT + " = ? AND " + Bookmarks.TITLE + " = ?",
+                                         new String[] { String.valueOf(parentId),
+                                                              folderName },
+                                         null,
+                                         null,
+                                         null);
+
+        if (c.moveToFirst()) {
+            id = c.getInt(c.getColumnIndex(Bookmarks._ID));
+        }
+        c.close();
+
+        return id;
+    }
+
     private Integer getBookmarkIdForGuid(SQLiteDatabase db, final String guid) {
         Cursor c = null;
 
         try {
             c = db.query(TABLE_BOOKMARKS,
                          new String[] { Bookmarks._ID },
                          Bookmarks.GUID + " = ?",
                          new String[] { guid },