public EGVRecord[] getRecentEGVsPages(int numOfRecentPages) { if (numOfRecentPages < 1) { throw new IllegalArgumentException("Number of pages must be greater than 1."); } Log.d(TAG, "Reading EGV page range..."); int recordType = Constants.RECORD_TYPES.EGV_DATA.ordinal(); int endPage = readDataBasePageRange(recordType); Log.d(TAG, "Reading " + numOfRecentPages + " EGV page(s)..."); numOfRecentPages = numOfRecentPages - 1; EGVRecord[] allPages = new EGVRecord[0]; for (int i = Math.min(numOfRecentPages, endPage); i >= 0; i--) { int nextPage = endPage - i; Log.d(TAG, "Reading #" + i + " EGV pages (page number " + nextPage + ")"); EGVRecord[] ithEGVRecordPage = readDataBasePage(recordType, nextPage); EGVRecord[] result = Arrays.copyOf(allPages, allPages.length + ithEGVRecordPage.length); System.arraycopy(ithEGVRecordPage, 0, result, allPages.length, ithEGVRecordPage.length); allPages = result; } Log.d(TAG, "Read complete of EGV pages."); return allPages; }
public EGVRecord[] getRecentEGVs() { int recordType = Constants.RECORD_TYPES.EGV_DATA.ordinal(); int endPage = readDataBasePageRange(recordType); return readDataBasePage(recordType, endPage); }