private void queryBdayToUpdate(JSONObject bd) throws JSONException {
   uChecksCounter++;
   CustomAsyncHandler handler = new CustomAsyncHandler(getContentResolver(), this);
   String[] projection = {EventTable.COLUMN_OID, EventTable.COLUMN_ID, EventTable.COLUMN_PIC_URL};
   Long begin = bdayToMillis(bd.getString("anon"), true);
   String selection =
       EventTable.COLUMN_CALENDAR_ID
           + " = \""
           + EventTable.CALENDAR_ID_FB_BIRTHDAYS
           + "\" AND "
           + EventTable.COLUMN_BEGIN
           + " >= "
           + Calendar.getInstance().getTimeInMillis()
           + " AND "
           + EventTable.COLUMN_OID
           + " = "
           + bd.getString("uid")
           + " AND "
           + EventTable.COLUMN_BEGIN_DAY
           + " != "
           + Time.getJulianDay(
               begin, TimeUnit.MILLISECONDS.toSeconds(TimeZone.getDefault().getOffset(begin)));
   // IDEA: setting the event JSONObject as cookie
   handler.startQuery(
       QUERY_BD_TO_UPDATE,
       bd,
       AgendaNowProvider.CONTENT_URI_EV,
       projection,
       selection,
       null,
       null);
 }
 public void queryFutureStoredBDays() {
   resetCounters();
   CustomAsyncHandler handler = new CustomAsyncHandler(getContentResolver(), this);
   String[] projection = {
     EventTable.COLUMN_OID, EventTable.COLUMN_UPDATED_TIME, EventTable.COLUMN_ID
   };
   String selection =
       EventTable.COLUMN_CALENDAR_ID
           + " = "
           + EventTable.CALENDAR_ID_FB_BIRTHDAYS
           + " AND "
           + EventTable.COLUMN_BEGIN
           + " >= "
           + today_begin.getTimeInMillis();
   if (isAppLaunchStage) {
     selection += " AND " + EventTable.COLUMN_BEGIN + " <= " + today_end.getTimeInMillis();
   }
   String orderBy = "date(" + EventTable.COLUMN_UPDATED_TIME + ") ASC";
   handler.startQuery(
       QUERY_FUTURE_STORED_BDS,
       null,
       AgendaNowProvider.CONTENT_URI_EV,
       projection,
       selection,
       null,
       orderBy);
 }
 private void queryBdayToInsert(JSONObject bd) throws JSONException {
   iChecksCounter++;
   CustomAsyncHandler handler = new CustomAsyncHandler(getContentResolver(), this);
   String[] projection = {EventTable.COLUMN_OID, EventTable.COLUMN_ID};
   String selection =
       EventTable.COLUMN_CALENDAR_ID
           + " = \""
           + EventTable.CALENDAR_ID_FB_BIRTHDAYS
           + "\" AND "
           + EventTable.COLUMN_OID
           + " = "
           + bd.getString("uid");
   // IDEA: setting the event JSONObject as cookie
   handler.startQuery(
       101, bd, AgendaNowProvider.CONTENT_URI_EV, projection, selection, null, null);
 }
 /*
  * Taking an event coming from FB JSON response as input parameter, this method is looking
  * for that event in the ContentProvider, selecting it only if its latest update time
  * is different by the one present in the JSON. If so, the event row is updated.
  */
 public void queryEventToUpdate(JSONObject ev) throws JSONException {
   uChecksCounter++;
   CustomAsyncHandler handler = new CustomAsyncHandler(getContentResolver(), this);
   String[] projection = {
     EventTable.COLUMN_OID,
     EventTable.COLUMN_UPDATED_TIME,
     EventTable.COLUMN_ID,
     EventTable.COLUMN_PIC_URL
   };
   String selection =
       EventTable.COLUMN_PLATFORM
           + " = \""
           + EventTable.PLATFORM_FACEBOOK
           + "\" AND "
           + EventTable.COLUMN_BEGIN
           + " >= "
           + today_begin.getTimeInMillis()
           + " AND "
           + EventTable.COLUMN_OID
           + " = "
           + ev.getString("eid")
           + " AND "
           + EventTable.COLUMN_UPDATED_TIME
           + " <> "
           + ev.getString("update_time");
   if (isAppLaunchStage) {
     selection += " AND " + EventTable.COLUMN_BEGIN + "<=" + today_end.getTimeInMillis();
   }
   // IDEA: setting the event JSONObject as cookie
   handler.startQuery(
       QUERY_EV_TO_UPDATE,
       ev,
       AgendaNowProvider.CONTENT_URI_EV,
       projection,
       selection,
       null,
       null);
 }
 /*
  * Taking an event coming from FB JSON response as input parameter, this method is looking
  * for that event in the ContentProvider. If not found, a new row is created, to insert the new event.
  */
 public void queryEventToInsert(JSONObject ev) throws JSONException {
   iChecksCounter++;
   CustomAsyncHandler handler = new CustomAsyncHandler(getContentResolver(), this);
   String[] projection = {
     EventTable.COLUMN_OID, EventTable.COLUMN_UPDATED_TIME, EventTable.COLUMN_ID
   };
   String selection =
       EventTable.COLUMN_PLATFORM
           + " = \""
           + EventTable.PLATFORM_FACEBOOK
           + "\" AND "
           + EventTable.COLUMN_OID
           + " = "
           + ev.getString("eid");
   // IDEA: setting the event JSONObject as cookie
   handler.startQuery(
       QUERY_EV_TO_INSERT,
       ev,
       AgendaNowProvider.CONTENT_URI_EV,
       projection,
       selection,
       null,
       null);
 }