sqlite数据库分页

本文介绍了如何在Android中使用SQLite进行数据库分页,通过创建数据库、插入数据、查询及展示分页效果,展示了如何利用GridView实现分页显示。文章包含创建数据库、插入数据、查询数据表的SQL命令,以及分页查询的实现方法。
摘要由CSDN通过智能技术生成

Android包含了常用于嵌入式系统的SQLite,免去了开发者自己移植安装的功夫。SQLite 支持多数 SQL92 标准,很多常用的SQL命令都能在SQLite上面使用,除此之外Android还提供了一系列自定义的方法去简化对SQLite数据库的操作。不过有跨平台需求的程序就建议使用标准的SQL语句,毕竟这样容易在多个平台之间移植。

先贴出本文程序运行的结果:

本文主要讲解了SQLite的基本用法,如:创建数据库,使用SQL命令查询数据表、插入数据,关闭数据库,以及使用GridView实现了一个分页栏(关于GridView的用法),用于把数据分页显示。

分页栏的pagebuttons.xml的源码如下:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_height="wrap_content" android:paddingBottom="4dip"  
  4.     android:layout_width="fill_parent">  
  5.     <TextView android:layout_width="wrap_content"  
  6.         android:layout_below="@+id/ItemImage" android:layout_height="wrap_content"  
  7.         android:text="TextView01" android:layout_centerHorizontal="true"  
  8.         android:id="@+id/ItemText">  
  9.     </TextView>  
  10. </RelativeLayout>    

 

main.xml的源码如下:

 

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical" android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent">  
  5.     <Button android:layout_height="wrap_content"  
  6.         android:layout_width="fill_parent" android:id="@+id/btnCreateDB"  
  7.         android:text="创建数据库"></Button>  
  8.     <Button android:layout_height="wrap_content"  
  9.         android:layout_width="fill_parent" android:text="插入一串实验数据" android:id="@+id/btnInsertRec"></Button>  
  10.     
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值