Getting the Item Count

Getting the Item Count

The get count operation returns the number of the result items instead of the items themselves. This can save you bandwidth and client processing.

Simple Count

To get items count of a content type, you have to execute the following code snippet:

public void getBooksCount(EverliveApp app) {
    RequestResult<Integer> booksCountResult = app.workWith().data(Book.class).getCount().executeSync();
    if (booksCountResult.getSuccess()) {
        Log.i("App_name", booksCountResult.getValue());
    }
}

Count with Filtering

You can get filtered items count by executing the following code snippet:

public void getRecentAddedBooksCount(EverliveApp app) {
    Date currentTime = new Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(currentTime);
    cal.add(Calendar.HOUR, -1);
    RequestResult<Integer> booksCountResult = app.workWith().data(Book.class).
                getCount().
                where(new ValueCondition("CreatedAt", cal.getTime(), ValueConditionOperator.GreaterThanOrEqualTo)).
                executeSync();
    if (booksCountResult.getSuccess()) {
        Log.i("App_name", booksCountResult.getValue());
    }
}
Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.