question: static void rename ( Context context , String originalFileName , String newFileName ) { File originalFile = context . getFileStreamPath ( originalFileName ) ; if ( originalFile . exists ( ) ) { Log . d ( "SavingHelper" , "renaming " + originalFileName + " size " + originalFile . length ( ) + " to " + newFileName ) ; File newFile = new File ( originalFile . getParent ( ) , newFileName ) ; if ( newFile . exists ( ) ) { context . deleteFile ( newFileName ) ; } originalFile . renameTo ( newFile ) ; } }
target:  Rename existing file in same directory if target file exists, delete Code nicked from http://stackoverflow.com/users/325442/mr-bungle