src/main/java/de/blau/android/util/SavingHelper.java
/**
     * Rename existing file in same directory if target file exists, delete Code nicked from
     * http://stackoverflow.com/users/325442/mr-bungle
     * 
     * @param context Android Context
     * @param originalFileName the original filename
     * @param newFileName the new filename
     */


@param context Android Context
@param originalFileName the original filename
@param newFileName the new filename
@param context Android Context @param originalFileName the original filename @param newFileName the new filename
private static void rename(@NonNull Context context, @NonNull String originalFileName, @NonNull String newFileName) {
        File originalFile = context.getFileStreamPath(originalFileName);
        if (originalFile.exists()) {
            Log.d(DEBUG_TAG, "renaming " + originalFileName + " size " + originalFile.length() + " to " + newFileName);
            File newFile = new File(originalFile.getParent(), newFileName);
            if (newFile.exists()) {
                context.deleteFile(newFileName);
            }
            if (!originalFile.renameTo(newFile)) {
                Log.e(DEBUG_TAG, "renaming failed!");
            }
        }
    }
private static void rename ( @ NonNull Context context , @ NonNull String originalFileName , @ NonNull String newFileName ) { File originalFile = context . getFileStreamPath ( originalFileName ) ; if ( originalFile . exists ( ) ) { Log . d ( DEBUG_TAG , "renaming " + originalFileName + " size " + originalFile . length ( ) + " to " + newFileName ) ; File newFile = new File ( originalFile . getParent ( ) , newFileName ) ; if ( newFile . exists ( ) ) { context . deleteFile ( newFileName ) ; } if ( ! originalFile . renameTo ( newFile ) ) { Log . e ( DEBUG_TAG , "renaming failed!" ) ; } } }
Rename existing file in same directory if target file exists, delete Code nicked from
 http://stackoverflow.com/users/325442/mr-bungle
Rename existing file in same directory if target file exists delete Code nicked from http : // stackoverflow . com / users / 325442 / mr - bungle