Question Detail

How can I request the database for Where Clause statement in SQLite.

I have tried below statement but it's not working Please Correct me how can i set Where Clause with my Select statement ( Query ).


Thread Reply

alex levine

- 10 months ago

this is the function of Where Clause statement in SQLite Query

Bold Words are written for Where Clause 

// Getting single album
public AlbumClass getAlbum(int id) {
    SQLiteDatabase db = this.getReadableDatabase();

    Cursor cursor = db.query(TABLE_ALBUMS, new String[]{KEY_ID, KEY_NAME, KEY_imgpath, KEY_DES, KEY_caption, KEY_albmdate, KEY_coverindx, KEY_imgDate, KEY_status, KEY_albumTypeID, KEY_quantity, KEY_ShippingPrice, KEY_addressID, KEY_priceParAlbum, KEY_totalprice}, KEY_ID + "=?", new String[]{String.valueOf(id)}, null, null, null, null);
    if (cursor != null)
        cursor.moveToFirst();
    AlbumClass Album = new AlbumClass(
            Integer.parseInt(cursor.getString(0)),
            cursor.getString(1),
            cursor.getString(2),
            cursor.getString(3),
            cursor.getString(4),
            cursor.getString(5),
            cursor.getString(6),
            cursor.getString(7),
            cursor.getString(8),
            cursor.getString(9),
            cursor.getString(10),
            cursor.getString(11),
            cursor.getString(12),
            cursor.getString(13),
            cursor.getString(14));
    // return Album
    return Album;
}