private void findStaleWebappDirectories(Context context,Set<File> directoriesToDelete){
  File webappBaseDirectory=getBaseWebappDirectory(context);
  Set<String> liveWebapps=new HashSet<String>();
  Set<Intent> baseIntents=getBaseIntentsForAllTasks();
  for (  Intent intent : baseIntents) {
    Uri data=intent.getData();
    if (data != null && TextUtils.equals(WebappActivity.WEBAPP_SCHEME,data.getScheme())) {
      liveWebapps.add(data.getHost());
    }
    ComponentName component=intent.getComponent();
    if (component != null) {
      String fullClassName=component.getClassName();
      int lastPeriodIndex=fullClassName.lastIndexOf(".");
      if (lastPeriodIndex != -1) {
        String className=fullClassName.substring(lastPeriodIndex + 1);
        if (className.startsWith(WEBAPP_DIRECTORY_NAME) && className.length() > WEBAPP_DIRECTORY_NAME.length()) {
          String activityIndex=className.substring(WEBAPP_DIRECTORY_NAME.length());
          liveWebapps.add(activityIndex);
        }
      }
    }
  }
  if (webappBaseDirectory != null) {
    File appDirectory=new File(context.getApplicationInfo().dataDir);
    String webappDirectoryAppBaseName=webappBaseDirectory.getName();
    File[] files=appDirectory.listFiles();
    if (files != null) {
      for (      File file : files) {
        String filename=file.getName();
        if (!filename.startsWith(webappDirectoryAppBaseName))         continue;
        if (filename.length() == webappDirectoryAppBaseName.length())         continue;
        directoriesToDelete.add(file);
      }
    }
    if (webappBaseDirectory.exists()) {
      files=webappBaseDirectory.listFiles();
      if (files != null) {
        for (        File file : files) {
          if (!liveWebapps.contains(file.getName()))           directoriesToDelete.add(file);
        }
      }
    }
  }
}

private void findStaleWebappDirectories ( Context context , Set < File > directoriesToDelete ) { File webappBaseDirectory = getBaseWebappDirectory ( context ) ; Set < String > liveWebapps = new HashSet < String > ( ) ; Set < Intent > baseIntents = getBaseIntentsForAllTasks ( ) ; for ( Intent intent : baseIntents ) { Uri data = intent . getData ( ) ; if ( data != null && TextUtils . equals ( WebappActivity . WEBAPP_SCHEME , data . getScheme ( ) ) ) { liveWebapps . add ( data . getHost ( ) ) ; } ComponentName component = intent . getComponent ( ) ; if ( component != null ) { String fullClassName = component . getClassName ( ) ; int lastPeriodIndex = fullClassName . lastIndexOf ( "." ) ; if ( lastPeriodIndex != - 1 ) { String className = fullClassName . substring ( lastPeriodIndex + 1 ) ; if ( className . startsWith ( WEBAPP_DIRECTORY_NAME ) && className . length ( ) > WEBAPP_DIRECTORY_NAME . length ( ) ) { String activityIndex = className . substring ( WEBAPP_DIRECTORY_NAME . length ( ) ) ; liveWebapps . add ( activityIndex ) ; } } } } if ( webappBaseDirectory != null ) { File appDirectory = new File ( context . getApplicationInfo ( ) . dataDir ) ; String webappDirectoryAppBaseName = webappBaseDirectory . getName ( ) ; File [ ] files = appDirectory . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { String filename = file . getName ( ) ; if ( ! filename . startsWith ( webappDirectoryAppBaseName ) ) continue ; if ( filename . length ( ) == webappDirectoryAppBaseName . length ( ) ) continue ; directoriesToDelete . add ( file ) ; } } if ( webappBaseDirectory . exists ( ) ) { files = webappBaseDirectory . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( ! liveWebapps . contains ( file . getName ( ) ) ) directoriesToDelete . add ( file ) ; } } } } }
finds all directories for web apps containing stale data . this includes all directories using the old pre - l directory structure , which used directories named * app_webappactivity * , as well as directories corresponding to webappactivities that are no longer listed in android ' s recents , since these will be unable to restore their data .
