dimanche 3 janvier 2016

how to get every row from SQLite from a function that returns only one row at a time

I have a SQLite DB which contains N rows, I need to retrieve every row by knowing the number of rows in the DB, what I've tried is this:

public CategoriesItem returnCategory(int index){
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor mRow= db.rawQuery("select * from " + TABLE_CATEGORY + " LIMIT 0, " + index, null);
        if (null!=mRow) {
            mRow.moveToNext();
            item.auto_id = Integer.toString(mRow.getInt(mRow.getColumnIndex(KEY_ID)));
            item.title = mRow.getString(mRow.getColumnIndex(KEY_CATEGORY_NAME));
            item.subTitle = mRow.getString(mRow.getColumnIndex(KEY_CATEGORY_DESCRIPTION));
        }

        return item;
    }

The problem is that it returns only the first row, everytime even if the index is not 1. What is wrong with the query? How can I get a single row values by knowing the amount of rows in the DB?

Aucun commentaire:

Enregistrer un commentaire