SQLiteDatabase db = ....;
Cursor cursor = db.rawQuery("“select count(*) from tableA", null);
while (cursor.moveToNext()) {
int personid = cursor.getInt(0); //获取第一列的值,第一列的索引从0开始
String name = cursor.getString(1);//获取第二列的值
int age = cursor.getInt(2);//获取第三列的值
Cursor cursor = db.rawQuery("“select count(*) from tableA", null);
while (cursor.moveToNext()) {
int personid = cursor.getInt(0); //获取第一列的值,第一列的索引从0开始
String name = cursor.getString(1);//获取第二列的值
int age = cursor.getInt(2);//获取第三列的值
解决方案 »
- android 在一个activity中点击GridView中的一个Item一(包含图片和名字),
- 在AppWidgetProvider派生类的方法中怎么操作成员变量
- 如何确保调用super.XXX()
- eclipse中无法找到android的adb.exe
- 提问:如何去掉listview之间的黑线
- 苦恼啊 帮我解决这个问题我愿意付现金
- 紧急求助 android如何通过post请求获得服务器返回string信息 急用但是本人被赶鸭子上架、、
- 做APN开关是遇到问题
- 遍历sdcard只能拿到一些小的音频文件
- 点击通知栏不启动LAUNCHER的activity而是起动自定义的activity
- 求教Android蓝牙串口开发OutputStream发送数据失败的问题。
- 电脑服务端和手机客户端UDP通信
为什么要用游标?
我用的是CppSQLite3DB类,里面execScalar函数直接返回记录数的
2. 1是代表着返回一条数据,而不是count(*)的值RecNo count(*)
1 0 只有这1条数据
奇怪,这个问题困扰我半天了,愣是没明白什么原因补充说明一下,有数据的情况下,返回值是正确的,用count(*)
比如我有3条数据,则返回的确实是 intCount = 3
一条数据返回的是 intCount = 1可就是为什么没数据的时候也返回的是 intCount = 1 ?? 这就有点纳闷了