public boolean deleteProfile ( ) { String [ ] profileDirs = { smallPrefsFolder , largePrefsFolder , cachePrefsFolder } ; // Assuming if any of those are main profile, skip the whole delete for ( String profileDir : profileDirs ) { if ( isMainProfile ( profileDir ) ) { logger . finer ( "Skipping profile deletion since '" + profileDir + "' is the main profile." ) ; return false ; } } for ( String profileDir : profileDirs ) { File currentDirHandle = new File ( profileDir ) ; if ( ! currentDirHandle . exists ( ) ) { logger . finer ( "Skipping profile deletion for '" + profileDir + "' since it doesn't exist." ) ; continue ; } boolean deleted = deleteFolder ( profileDir ) ; if ( ! deleted ) { final int retryIntervalMs = 500 ; final int retryMaxCount = 10 ; int retryCount = 0 ; boolean ok = false ; logger . warning ( "Profile could not be deleted, retrying..." ) ; do { try { Thread . sleep ( retryIntervalMs ) ; } catch ( InterruptedException e ) { // fall through } ok = deleteFolder ( profileDir ) ; retryCount ++ ; if ( retryCount > retryMaxCount ) { break ; } } while ( ! ok ) ; if ( ! ok ) { logger . severe ( "Could not delete profile in '" + profileDir + "'. Skipping further deletion." ) ; return false ; } else { logger . warning ( "Deleted profile, retry count = " + retryCount ) ; } } else { logger . finer ( "Deleted profile in '" + profileDir + "'" ) ; } } return true ; }
Deletes prefs folders for Does nothing if prefs folders are default main user profile