title: Firebase Set key of the root Id
body: <p>I just wonder how to set the root id with a key of my own instead of the Push() key that gets generated inside the while loop at the top..</p>
  
  <pre><code>  -Waypoint  
      -RootID &lt;-- This key
        -Points
  </code></pre>
  
  <p>....................</p>
  
  <pre><code> LinkedHashMap&lt;String, Object&gt; pointHolder = new LinkedHashMap&lt;&gt;();
   LinkedHashMap&lt;String, Object&gt; waypointHolder = new LinkedHashMap&lt;&gt;();
  
   waypointsUrl = Constants.FIREBASE_URL + "/users/" + mUserId + "/waypoints";
          mainRef = new Firebase(waypointsUrl);
  </code></pre>
  
  <p>.................</p>
  
  <p><strong>UPDATED CODE</strong></p>
  
  <pre><code>            while (isFirstTime) {
                  // Generates root id for date
                  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                  Date date = new Date();
                  mLastUpdateTime = dateFormat.format(date);
  
                  // Generates root id
                   mainRefKey = mainRef.push();
  
                  isFirstTime = false;
              }
  
  
              // Generates new id for point
              Firebase wayRef1 = mainRefKey.push();
              String pointKey = wayRef1.getKey();
  
  
              // Create Waypoint &gt; Point &gt;  put lat and lon
              LinkedHashMap&lt;String, Object&gt; latLng = new LinkedHashMap&lt;String, Object&gt;();
              latLng.put("latitude", 123);
              latLng.put("longitude", 123);
  
  
              // Puts lat and lon  ** under a Point Key **
              pointHolder.put(pointKey, latLng);
  
  
              // Waypoint &gt; POINT (contains multiple points)
              waypointHolder.put("points", pointHolder);
              waypointHolder.put("timeStamp", "24/3-2016");
              waypointHolder.put("travelType", "travel");
  
  
              // ROOT ID &gt; Waypoint
              mainRefKey.updateChildren(waypointHolder);
          }
      });
  </code></pre>
  
  <p>Picture of the desired structure:</p>
  
  <p><a href="https://i.stack.imgur.com/Qbb3h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qbb3h.png" alt="enter image description here"></a></p>