public static void loadFavoritesFromDb() {
   FavoritesData.clear();
   String where = " launchTimes > 0 ";
   final Cursor c =
       mFavoritesDbOperation.query(
           FavoritesDatabaseOperation.TABLE_FAVORITE, null, where, null, null);
   try {
     final int idIndex = c.getColumnIndexOrThrow(FavoritesDatabaseOperation.Favorites._ID);
     final int packageIndex =
         c.getColumnIndexOrThrow(FavoritesDatabaseOperation.Favorites.PACKAGE_NAME);
     final int launchTimesIndex =
         c.getColumnIndexOrThrow(FavoritesDatabaseOperation.Favorites.LAUNCH_TIMES);
     FavoritesAppInfo appInfo;
     String packageDescription;
     long id;
     while (c.moveToNext()) {
       try {
         id = c.getLong(idIndex);
         packageDescription = c.getString(packageIndex);
         appInfo = FavoritesData.getAppInfo(packageDescription);
         if (appInfo != null) {
           appInfo.id = id;
           appInfo.launchTimes = c.getLong(launchTimesIndex);
           FavoritesData.add(appInfo);
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } finally {
     if (c != null) {
       c.close();
     }
   }
 }
 private FavoritesAppInfo removeApp(final String[] packages, int i) {
   FavoritesAppInfo appInfo = FavoritesData.getAppInfo(packages[i]);
   if (appInfo != null) {
     FavoritesData.mAppsAll.remove(appInfo);
   }
   appInfo = FavoritesData.getDatasApp(packages[i]);
   if (appInfo != null) {
     FavoritesData.datas.remove(appInfo);
   }
   deleteItemFromDatabase(mContext, appInfo);
   return appInfo;
 }
 private void updateApp(final String[] packages, int i) {
   ApplicationInfo applicationInfo;
   try {
     applicationInfo = mPackageManager.getApplicationInfo(packages[i], 0);
     FavoritesAppInfo appInfo = FavoritesData.getAppInfo(packages[i]);
     if (appInfo != null) {
       appInfo.appName = applicationInfo.loadLabel(mPackageManager).toString();
       appInfo.appIntent =
           mPackageManager.getLaunchIntentForPackage(applicationInfo.packageName);
       appInfo.appIcon = applicationInfo.loadIcon(mPackageManager);
     }
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
 }