Android examples for Database:SQL Query
get Page Sorted By Id from database table
//package com.book2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { public static final int PAGE_SIZE = 50; public static Cursor getPageSortedById(SQLiteDatabase db, String tableName, boolean desc, int pageNum) { return getPageSortedByKey(db, tableName, "id", desc, pageNum); }//from w w w . ja v a 2 s. c om public static Cursor getPageSortedByKey(SQLiteDatabase db, String tableName, String keyColumn, boolean desc, int pageNum) { return db.rawQuery("SELECT * " + "FROM " + tableName + " " + "ORDER BY " + keyColumn + " " + (desc ? "DESC" : "") + " " + "LIMIT " + PAGE_SIZE + " " + "OFFSET " + (PAGE_SIZE * pageNum) + ";", null); } }