Limit the query in CursorLoader

前端 未结 3 1112
渐次进展
渐次进展 2021-02-04 03:06

I am trying to query data from sqlite db through CursorLoader. When i go through the documentation in android developer website, i can\'t find the limit query.

Cu

3条回答
  •  青春惊慌失措
    2021-02-04 03:27

    I realize this is late, but sandrstar gave me an idea which was to use the Uri that you pass into the ContentProvider and append the limit as the last path segment to it using

    Uri.withAppendedPath("uri" "/" + limitNumber);
    

    Then inside your content provider, in your URI matcher make sure you match

    MATCHER.addURI("authority", "uri" + "/#", matchInt); 
    

    Then in your query, check for the matchInt that you matched the URI to and get the last path segment

    uri.getLastPathSegment();
    

    Which will be your limit and then use what sandrstar recommended with the SQLiteQueryBuilder.

    Just figured it might be nice to have a good technique to get your parameter to the Provider. Hope this helps!

提交回复
热议问题