Search code examples
androidsqliteandroid-cursor

Having issues limiting the return size of a cursor


I have this code

Cursor mCursor = this.getContentResolver().query(
            PlayerContentProviderDB.CONTENT_URI, PLAYERS_PROJECTION, null, null,
             Players.SCORE +" ASC"
             + " LIMIT 2");

I am having trouble getting the limit to work. I have read this format works but it is not in this case. Currently I am aware that my sorting clause does not work as intended either and I do not know why (Please see How to sort a cursor based on a time string).

Is there a reason why neither statement is working? If so how can I fix it?


Solution

  • I found out that the above code is fine. There error lies in the fact that my query method is being called twice for unknown reasons with sortOrder == null on the second call.