vendredi 30 octobre 2015

Only get 1st element of TABLE in SQLite

I have this code:

public LinkedList<Product> getAllProduct(String idtask){
    LinkedList<Product> products = new LinkedList<Product>();
    Cursor localCursor = this.getWritableDatabase().rawQuery("SELECT * FROM "+TABLE_PRODUCT+" WHERE "+KEY_ID_PRODUCT_TASK+"='"+idtask+"'", null);
    Product product;
    if (localCursor.moveToFirst())
        do {
            product = new Product();
            product.setKEY_ID_UNIQUE_PRODUCT(localCursor.getString(0));
            product.setKEY_ID_PRODUCT_TASK(localCursor.getString(1));
            product.setKEY_ID_PRODUCT(localCursor.getString(2));
            product.setKEY_NAME_PRODUCT(localCursor.getString(3));
            product.setKEY_QTY_PRODUCT(localCursor.getString(4));
            product.setKEY_SIZE_PRODUCT(localCursor.getString(5));
            products.add(product);
        } while (localCursor.moveToNext());
    return products;
}

I only get 1 row, when with a particular IdTasks, I have to get 2 elements. Please Help me, I don't Know whats the problem. Because, when I debugging I add 2 products with this IdTask in the Table product, but when I try to get these products with this IdTask, I only get the first.

Aucun commentaire:

Enregistrer un commentaire