Using the LIMIT statement in a SQLite query

前端 未结 3 2021
栀梦
栀梦 2020-11-27 16:38

I have a query that selects rows in a ListView without having a limit. But now that I have implemented a SharedPreferences that the user can select

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 16:59

    Due to this bug which also doesn't allow for negative limits

    8,-1

    I had to use this workaround

    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables(table);
    String query = builder.buildQuery(projection, selection, null, null, null, sortOrder, null);
    query+=" LIMIT 8,-1";
    

提交回复
热议问题