如何在不使用moveToFirst()
的情况下获取光标的行数?
(是否可以在不执行.moveToFirst()的情况下执行.getCount()???)
logcat的
11-29 13:37:40.370:E / SQLiteLog(8459):( 11)数据库损坏 [00bb9c9ce4]的第62665行
11-29 13:37:40.370:E / SQLiteLog(8459):( 11)语句在44处中止: [选择pos,定义,样本FROM单词INNER JOIN意义ON word.wordid = sense.wordid INNER JOIN synset ON sense.synsetid = synset.synsetid LEFT JOIN示例ON sample.synsetid = syn
代码
try {
if (sqldb2 == null || !sqldb2.isOpen()) {
dbobj2 = new SqLiteConection(context,
"/mnt/sdcard/sk2.db");
sqldb2 = dbobj2.openDB2();
}
// if(sqldb2!=null){
cursor_n = sqldb2.rawQuery(NOUN, null);
cursor_n.moveToFirst();
if (cursor_n.getCount() > 0) {
if (cursor_n != null) {
if (cursor_n.moveToFirst()) {
do {
String strin = cursor_n
.getString(cursor_n
.getColumnIndex("definition"));
d_noun_List.add(strin);
} while (cursor_n.moveToNext());
searchData_DTO.setD_nounList(d_noun_List);
}
}
cursor_n.close();
}else {
break;
// record not found
}
} catch (Exception e) {
Log.d("in Exception", "reason" + e);}
答案 0 :(得分:0)
使用.getCount函数获取行数
Cursor.getCount()
答案 1 :(得分:0)
要获得行数,您可以使用:
cursor_n.cursor.getCount();
答案 2 :(得分:0)
通过备份db
完成自己