mercredi 5 août 2015

Select row if text inside contains a specific text

So i have a input called month, and i wanted to make a query so that from all the rows in a custom listview, the rows containing that specific month is returned. This is my code in my DBAdpater. What must i do so that the db returns all the rows that contain that specific month. The format that my date is saved is 05/06/15. The string sent in the params is "/08/".

public Cursor getRowsFromMonth(String month){
    String[] FROM = { 
            KEY_ROWID,KEY_DATE, KEY_DESCRIPTION, KEY_CATEGORY, KEY_AMOUNT, KEY_PAIDBY
    };

    String where = "date=?";

    String[] whereArgs = new String[] { 
            "%"+ month+"%"
    };

    return db.query(DATABASE_TABLE, FROM, where, whereArgs, null, null, null);
}

Aucun commentaire:

Enregistrer un commentaire