returnLimitedList(i...">

Using Constraints () and offset () in QueryBuilder (ANDROID, ORMLITE)

@SuppressWarnings("deprecation")
public List<Picture> returnLimitedList(int offset, int end) {
    List<Picture> pictureList = new ArrayList<Picture>();
    int startRow = offset;
    int maxRows = end;
    try {
        QueryBuilder<Picture, Integer> queryBuilder = dao.queryBuilder();
        queryBuilder.offset(startRow).limit(maxRows);
        pictureList = dao.query(queryBuilder.prepare());
    } catch (SQLException e) {
        e.printStackTrace();
    }

    return pictureList;
}
  • I have an image table in the database and should return a limited list of 20 rows at a time.
  • But when I use ex: QueryBuilder.offset (11) .limit (30);
  • I cannot return a list limited to 20 lines.
  • The list comes to me only with a limit.
  • As if the offset always stays with a value of 0
  • ex: (0 - 30)

  • Is there any other way to return a restricted list for the start index and end index?

  • Can anyone help me?
+5
source share
1 answer

This question was asked two months ago, but I will answer if someone came across the same problem as me.

, offset , , SQLite Documentations

OFFSET, M , SELECT, N , M N , OFFSET LIMIT, .

30 , # 11.

, :

queryBuilder.offset(startRow).limit(20);

limit , , .

pictureList = dao.query(queryBuilder.prepare());

List , pictureList.get(0)

: @Gray

+12

All Articles