/greenDAOPagination

Pagination with greenDAO

Primary LanguageJava

greenDAOPagination Service

Purpose:

This greenDAO pagination library service is to paginate through your greenDAO. You can get the items from dao object in pagination in single line.
Example
userDAOPagination.getRecordsForPage(1);
which results the records for first page(Where is 1 is the pageNumber).

How to use:

  • Copy the GreenDAODataPaginationService.java into your project
  • Call like below
  • // 10 is the items per page i want to get
     GreenDAODataPaginationService userDAOPagination = new GreenDAODataPaginationService(userDao,10,userDao.class);
                ArrayList <Object> users = userDAOPagination.getRecordsForPage(1);
                // This prints the first userID
                System.out.println(((User)users.get(0)).getUserID());

    Example:

    Lets take you have a userDAO object referring table like below

    Then
    To paginate through this table with 10 items per page
    Step1: GreenDAODataPaginationService userDAOPagination = new GreenDAODataPaginationService(userDao,10,userDao.class);
    Step2: userDAOPagination.getRecordsForPage(1); // ==> Returns Records 1 to 10
    userDAOPagination.getRecordsForPage(2); // ==> Returns Records 11 to 20

    Basic useful feature list:

  • You can define the the number of items per page.
  • Get the items by specifying the page Number.