首页 > 移动平台 > 详细

android中cursor对象的使用

时间:2016-05-09 20:17:11      阅读:233      评论:0      收藏:0      [点我收藏+]

cursor对象是使用行来存储数据的,你要使用它获得数据,就必须知道每一列的数据名称以及他的数据类型才能获得对象数据

常见的方法:

.close()关闭资源:记住,所有的资源对象使用完成后都要主动关闭才行

.moveToNext()移动到下一行

.moveToFirst()移动到第一行

.getColumnCount()返回列数

.getColumnIndex("")返回列名称

.getString(.getColumnIndex(""))返回获得列名称对应的数据

if(cursor!=null)
    while(cursor.moveToNext()){
        String a=cursor.getString(cursor.getColumnIndex("column1"));
        int b=cursor.getInt(cursor.getcolumnIndex("column2"));
    }
    cursor.close();
}

 

android中cursor对象的使用

原文:http://www.cnblogs.com/zzy-frisrtblog/p/5475073.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!