/** Update favorites bus stops into route stops. */
 @SuppressWarnings("deprecation")
 public static void updateBusStopsToRouteStops(Context context) {
   MyLog.v(TAG, "updateBusStopsToRouteStops()");
   final ContentResolver contentResolver = context.getContentResolver();
   List<Fav> busStopFavs =
       DataManager.findFavsByTypeList(contentResolver, Fav.KEY_TYPE_VALUE_BUS_STOP);
   MyLog.d(
       TAG,
       "Favorite bus stops to upgrade: %s",
       (busStopFavs == null ? null : busStopFavs.size()));
   if (busStopFavs != null) {
     for (Fav busStopFav : busStopFavs) {
       try {
         final int stopId = Integer.valueOf(busStopFav.getFkId());
         final int routeId = Integer.valueOf(busStopFav.getFkId2());
         final String uid = RouteStop.getUID(StmBusManager.AUTHORITY, stopId, routeId);
         Fav newRouteStopFav = new Fav();
         newRouteStopFav.setType(Fav.KEY_TYPE_VALUE_AUTHORITY_ROUTE_STOP);
         newRouteStopFav.setFkId(uid);
         final boolean alreadyFavorite =
             DataManager.findFav(contentResolver, Fav.KEY_TYPE_VALUE_AUTHORITY_ROUTE_STOP, uid)
                 != null;
         if (alreadyFavorite) {
           MyLog.d(TAG, "Favorite bus stop %s already migrated.", busStopFav);
         } else {
           final boolean added = DataManager.addFav(contentResolver, newRouteStopFav) != null;
           if (!added) {
             MyLog.d(TAG, "Favorite bus stop %s not converted to route stop!", busStopFav);
             continue; // don't remove not migrated
           }
         }
         final boolean deleted = DataManager.deleteFav(contentResolver, busStopFav.getId());
         if (!deleted) {
           MyLog.d(TAG, "Old favorite bus stop %s migrated but not deleted!", busStopFav);
         }
       } catch (Throwable t) {
         MyLog.w(TAG, t, "Error while migrating favorite bus stop %s to route stop!", busStopFav);
       }
     }
   }
   MyLog.d(TAG, "updateBusStopsToRouteStops() > DONE");
 }
 /**
  * Set the DEMO mode with favorites and other settings...
  *
  * @param context the context
  */
 public static void setDemoMode(Context context) {
   // set favorites
   Fav newFav = new Fav();
   newFav.setType(Fav.KEY_TYPE_VALUE_AUTHORITY_ROUTE_STOP);
   newFav.setFkId(RouteStop.getUID(StmBusManager.AUTHORITY, 54321, 10));
   DataManager.addFav(context.getContentResolver(), newFav);
   newFav.setFkId(RouteStop.getUID(StmBusManager.AUTHORITY, 52509, 24));
   DataManager.addFav(context.getContentResolver(), newFav);
   newFav.setFkId(RouteStop.getUID(StmBusManager.AUTHORITY, 55140, 48));
   DataManager.addFav(context.getContentResolver(), newFav);
   newFav.setFkId(RouteStop.getUID(StmBusManager.AUTHORITY, 11, 1)); // Berri-UQAM - Verte
   DataManager.addFav(context.getContentResolver(), newFav);
   newFav.setFkId(RouteStop.getUID(StmBusManager.AUTHORITY, 9, 2)); // Mont-Royal - Orange
   DataManager.addFav(context.getContentResolver(), newFav);
   newFav.setType(Fav.KEY_TYPE_VALUE_BIKE_STATIONS);
   newFav.setFkId("6415"); // Wilson / Sherbrooke
   DataManager.addFav(context.getContentResolver(), newFav);
   SupportFactory.get().backupManagerDataChanged(context);
 }
 /** Update favorites subway stations into route stops. */
 @SuppressWarnings("deprecation")
 public static void updateSubwayStationsToRouteStops(Context context) {
   MyLog.v(TAG, "updateSubwayStationsToRouteStops()");
   final ContentResolver contentResolver = context.getContentResolver();
   List<Fav> subwayStationFavs =
       DataManager.findFavsByTypeList(contentResolver, Fav.KEY_TYPE_VALUE_SUBWAY_STATION);
   MyLog.d(
       TAG,
       "Favorite subway stations to upgrade: %s",
       (subwayStationFavs == null ? null : subwayStationFavs.size()));
   if (subwayStationFavs != null) {
     for (Fav subwayStationFav : subwayStationFavs) {
       try {
         boolean allStopRoutesMigrated = true;
         final int stopId = Integer.valueOf(subwayStationFav.getFkId());
         List<Route> stopRoutes = StmSubwayManager.findRoutesWithStopIdList(context, stopId);
         if (stopRoutes == null || stopRoutes.size() == 0) {
           MyLog.d(TAG, "Favorite subway station %s route(s) not found!", subwayStationFav);
           allStopRoutesMigrated = false; // no stop routes!
         }
         if (stopRoutes != null) {
           for (Route stopRoute : stopRoutes) {
             final int routeId = stopRoute.id;
             final String uid = RouteStop.getUID(StmSubwayManager.AUTHORITY, stopId, routeId);
             Fav newRouteStopFav = new Fav();
             newRouteStopFav.setType(Fav.KEY_TYPE_VALUE_AUTHORITY_ROUTE_STOP);
             newRouteStopFav.setFkId(uid);
             final boolean alreadyFavorite =
                 DataManager.findFav(contentResolver, Fav.KEY_TYPE_VALUE_AUTHORITY_ROUTE_STOP, uid)
                     != null;
             if (alreadyFavorite) {
               MyLog.d(TAG, "Favorite subway station %s already migrated.", newRouteStopFav);
             } else {
               final boolean added = DataManager.addFav(contentResolver, newRouteStopFav) != null;
               if (!added) {
                 MyLog.d(
                     TAG,
                     "Favorite subway station %s not converted to route stop!",
                     subwayStationFav);
                 allStopRoutesMigrated = false;
               }
             }
           }
         }
         if (!allStopRoutesMigrated) {
           MyLog.d(
               TAG, "Favorite subway station %s not converted to route stop!", subwayStationFav);
           continue; // don't remove not migrated
         }
         final boolean deleted = DataManager.deleteFav(contentResolver, subwayStationFav.getId());
         if (!deleted) {
           MyLog.d(
               TAG, "Old favorite subway station %s migrated but not deleted!", subwayStationFav);
         }
       } catch (Throwable t) {
         MyLog.w(
             TAG,
             t,
             "Error while migrating favorite subway station %s to route stop!",
             subwayStationFav);
       }
     }
   }
   MyLog.d(TAG, "updateSubwayStationsToRouteStops() > DONE");
 }