public List<Long> deleteEmptyFolders(){
  ArrayList<Long> folderIds=new ArrayList<Long>();
  SQLiteDatabase db=mOpenHelper.getWritableDatabase();
  db.beginTransaction();
  try {
    String selection=LauncherSettings.Favorites.ITEM_TYPE + " = " + LauncherSettings.Favorites.ITEM_TYPE_FOLDER+ " AND "+ LauncherSettings.Favorites._ID+ " NOT IN (SELECT "+ LauncherSettings.Favorites.CONTAINER+ " FROM "+ TABLE_FAVORITES+ ")";
    Cursor c=db.query(TABLE_FAVORITES,new String[]{LauncherSettings.Favorites._ID},selection,null,null,null,null);
    while (c.moveToNext()) {
      folderIds.add(c.getLong(0));
    }
    c.close();
    if (folderIds.size() > 0) {
      db.delete(TABLE_FAVORITES,Utilities.createDbSelectionQuery(LauncherSettings.Favorites._ID,folderIds),null);
    }
    db.setTransactionSuccessful();
  }
 catch (  SQLException ex) {
    Log.e(TAG,ex.getMessage(),ex);
    folderIds.clear();
  }
 finally {
    db.endTransaction();
  }
  return folderIds;
}

public List < Long > deleteEmptyFolders ( ) { ArrayList < Long > folderIds = new ArrayList < Long > ( ) ; SQLiteDatabase db = mOpenHelper . getWritableDatabase ( ) ; db . beginTransaction ( ) ; try { String selection = LauncherSettings . Favorites . ITEM_TYPE + " = " + LauncherSettings . Favorites . ITEM_TYPE_FOLDER + " AND " + LauncherSettings . Favorites . _ID + " NOT IN (SELECT " + LauncherSettings . Favorites . CONTAINER + " FROM " + TABLE_FAVORITES + ")" ; Cursor c = db . query ( TABLE_FAVORITES , new String [ ] { LauncherSettings . Favorites . _ID } , selection , null , null , null , null ) ; while ( c . moveToNext ( ) ) { folderIds . add ( c . getLong ( 0 ) ) ; } c . close ( ) ; if ( folderIds . size ( ) > 0 ) { db . delete ( TABLE_FAVORITES , Utilities . createDbSelectionQuery ( LauncherSettings . Favorites . _ID , folderIds ) , null ) ; } db . setTransactionSuccessful ( ) ; } catch ( SQLException ex ) { Log . e ( TAG , ex . getMessage ( ) , ex ) ; folderIds . clear ( ) ; } finally { db . endTransaction ( ) ; } return folderIds ; }
deletes any empty folder from the db .
