[Demonstration 1]

[Buggy Method]
Cursor queryfromFavorite_Name(String Name) {
    Cursor cursor = database.query(MySQLiteHelper.TABLE_FAVORITES, allColumns, MySQLiteHelper.COLUMN_NAME + " = " + Name, null, null, null, null);
    return cursor;
}

[Buggy Hunk]
allColumns, MySQLiteHelper.COLUMN_NAME + " = " + Name, null,

[Patch]
allColumns, MySQLiteHelper.COLUMN_NAME + " = '" + Name+"'", null,

[Demonstration 2]

[Buggy Method]
public String getAuthorsAsString() {
    StringBuilder builder = new StringBuilder();
    if (mAuthors == null && mAuthors.isEmpty()) {
        return "";
    }
    for (String author : mAuthors) {
        builder.append(author);
        builder.append(", ");
    }
    builder.delete(builder.length() - 2, builder.length() - 1);
    return builder.toString();
}

[Buggy Hunk]
if (mAuthors == null && mAuthors.isEmpty()) {

[Patch]
if (mAuthors == null || mAuthors.isEmpty()) {

[Demonstration 3]

[Buggy Method]
private boolean queryYelp(String lat, String lon, String input, String filter, int offset, int whichAsyncTask) {
    // Build Yelp request.
    try {
        URL url;
        HttpURLConnection urlConnection;
        String requestUrl = "https://api.yelp.com/v3/businesses/search";
        StringBuilder builder = new StringBuilder(requestUrl);
        builder.append("?term=").append("food");
        builder.append("&limit=" + 50);
        builder.append("&offset=").append(offset);
        // Check if user wants to filter by categories.
        if (filter.length() != 0)
            builder.append("&categories=").append(filter);
        // Check if the user wants to filter by price range.
        StringBuilder priceBuilder = new StringBuilder("");
        ArrayList<String> priceRange = new ArrayList<>();
        if (priceOne.isChecked() || priceTwo.isChecked() || priceThree.isChecked() || priceFour.isChecked())
            builder.append("&price=");
        if (priceOne.isChecked())
            priceRange.add("1");
        if (priceTwo.isChecked())
            priceRange.add("2");
        if (priceThree.isChecked())
            priceRange.add("3");
        if (priceFour.isChecked())
            priceRange.add("4");
        // Making sure to prevent trailing commas in price range list.
        for (String elem : priceRange) {
            priceBuilder.append(elem);
            if (priceRange.indexOf(elem) != (priceRange.size() - 1))
                priceBuilder.append(",");
        }
        builder.append(priceBuilder.toString());
        if (openAtTimeFilter != 0)
            builder.append("&open_at=").append(openAtTimeFilter);
        if (LocationProviderHelper.useGPS) {
            builder.append("&latitude=").append(lat);
            builder.append("&longitude=").append(lon);
        } else {
            builder.append("&location=").append(input);
        }
        requestUrl = builder.toString();
        Log.d("RRG", "request made: " + requestUrl);
        url = new URL(requestUrl);
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.addRequestProperty("Authorization", String.format("Bearer %s", accessToken));
        urlConnection.setConnectTimeout(10 * 1000);
        urlConnection.setReadTimeout(10 * 1000);
        // Make connection and read the response.
        urlConnection.connect();
        BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String buf, jsonString;
        while ((buf = br.readLine()) != null) sb.append(buf);
        br.close();
        jsonString = sb.toString();
        JSONObject response = new JSONObject(jsonString);
        // Get JSON array that holds the listings from Yelp.
        JSONArray jsonBusinessesArray = response.getJSONArray("businesses");
        int length = jsonBusinessesArray.length();
        Log.d("RRG", "json response array length: " + length);
        // This occurs if a network communication error occurs or if no restaurants were found.
        if (length <= 0) {
            errorInQuery = TypeOfError.NO_RESTAURANTS;
            return false;
        }
        for (int i = 0; i < length; i++) {
            if (whichAsyncTask == 0 && initialYelpQuery.isCancelled())
                break;
            Restaurant res = convertJSONToRestaurant(jsonBusinessesArray.getJSONObject(i));
            if (res != null)
                restaurants.add(res);
        }
        if (restaurants.isEmpty()) {
            errorInQuery = TypeOfError.NO_RESTAURANTS;
            return false;
        }
    } catch (JSONException e) {
        if (e.getMessage().contains("No value for businesses"))
            errorInQuery = TypeOfError.NO_RESTAURANTS;
        else if (e.getMessage().contains("No value for"))
            errorInQuery = TypeOfError.MISSING_INFO;
        e.printStackTrace();
        return false;
    } catch (FileNotFoundException e) {
        errorInQuery = TypeOfError.INVALID_LOCATION;
        e.printStackTrace();
        return false;
    } catch (Exception e) {
        if (e.getMessage().contains("timed out"))
            errorInQuery = TypeOfError.TIMED_OUT;
        e.printStackTrace();
        return false;
    }
    errorInQuery = TypeOfError.NO_ERROR;
    return true;
}

[Buggy Hunk]
builder.append("&categories=").append(filter);

[Patch]
builder.append("&categories=").append(filter.toLowerCase());