[Demonstration 1]

[Buggy Method]
public static void backupFile(String fileFolder, String filename, String backupFolder) {
    final SimpleDateFormat sdf = new SimpleDateFormat(BACKUPFILE_DATEFORMAT);
    if (backupFolder == null || backupFolder.trim().equals("")) {
        backupFolder = fileFolder;
    }
    String backupFilename = filename + BACKUPFILE_PREFIX + sdf.format(new Date());
    String fullBackupFilename = addTrailingSlash(backupFolder) + backupFilename;
    File file = new File(addTrailingSlash(fileFolder) + filename);
    File backupFile = new File(fullBackupFilename);
    String fullBackupFilenamePath = backupFile.getAbsolutePath();
    File destinationPath = new File(fullBackupFilenamePath);
    destinationPath.mkdirs();
    if (file.exists()) {
        file.renameTo(backupFile);
    }
}

[Buggy Hunk]
String fullBackupFilenamePath = backupFile.getAbsolutePath();

[Patch]
String fullBackupFilenamePath = backupFile.getAbsolutePath().substring(0,backupFile.getAbsolutePath().lastIndexOf(File.separator));

[Demonstration 2]

[Buggy Method]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //Check for updates but only once a day
    //so get the date from the settings when
    //the last update check was done
    Date currentDate = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
    SharedPreferences settings = getSharedPreferences("choreSettings", MODE_PRIVATE);
    String updateCheckDate = settings.getString("updateCheckDate", "never");
    Boolean notificationService = settings.getBoolean("notificationService", false);
    ip = settings.getString("ip", "myserver2.mybluemix.net");
    System.out.println("IP: " + ip);
    if (ip.equals("")) {
        ip = "myserver2.mybluemix.net";
    }
    System.out.println("Last checked:" + updateCheckDate);
    if (!(sdf.format(currentDate).equals(updateCheckDate))) {
        checkForUpdates();
    }
    Context context = super.getApplicationContext();
    if (notificationService) {
        //Set the boot receiver
        System.out.println("Started BootReceiver");
        ComponentName receiver = new ComponentName(context, BootReceiver.class);
        PackageManager pm = context.getPackageManager();
        pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        //Set the alarm
        System.out.println("[ChoreApp] AlarmManager: Alarm set");
        AlarmManager alarmMgr;
        PendingIntent alarmIntent;
        alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        Intent intent2 = new Intent(this, AlarmReceiver.class);
        alarmIntent = PendingIntent.getBroadcast(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
        alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_FIFTEEN_MINUTES, AlarmManager.INTERVAL_FIFTEEN_MINUTES, alarmIntent);
    } else {
        System.out.println("Notification Service was not started because it was disabled by the user");
        AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        Intent i = new Intent(context, AlarmReceiver.class);
        PendingIntent p = PendingIntent.getBroadcast(context, 0, i, 0);
        am.cancel(p);
        p.cancel();
        System.out.println("Service stopped");
    }
}

[Buggy Hunk]
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");

[Patch]
@SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");

[Demonstration 3]

[Buggy Method]
private File getFile(String datasetName) {
    StringBuilder builder = new StringBuilder();
    builder.append(configuration.getString(PRE_DATA_DIR)).append(File.separator);
    builder.append(datasetName).append(File.separator);
    builder.append(DATASET_FILENAME.concat(".xml"));
    return new File(builder.toString());
}

[Buggy Hunk]
builder.append(DATASET_FILENAME.concat(".xml"));

[Patch]
builder.append(DATASET_FILENAME);