public void rename(String iOldName, String iNewName) { for (OFile file : files) { final String osFileName = file.getName(); if (osFileName.startsWith(name)) { final File newFile = new File( storage.getStoragePath() + "/" + iNewName + osFileName.substring(osFileName.lastIndexOf(name) + name.length())); for (OStorageFileConfiguration conf : config.infoFiles) { if (conf.parent.name.equals(name)) conf.parent.name = iNewName; if (conf.path.endsWith(osFileName)) conf.path = new String(conf.path.replace(osFileName, newFile.getName())); } boolean renamed = file.renameTo(newFile); while (!renamed) { OMemoryWatchDog.freeMemoryForResourceCleanup(100); renamed = file.renameTo(newFile); } } } }