public Cursor getBiggestInTheColumn()
{
return db.query(HEADER_TABLE, null,"MAX(key_Division)", null, null, null, null);
}
我将此方法称为Cursor cc=db.getBiggestInTheColumn();
但它强行关闭了应用程序。请帮助我
答案 0 :(得分:26)
您可以使用simpleQueryForLong
并相应地投射它。
public int getMaxColumnData() {
mDb = mDbManager.getReadableDatabase();
final SQLiteStatement stmt = mDb
.compileStatement("SELECT MAX(column) FROM Table");
return (int) stmt.simpleQueryForLong();
}
答案 1 :(得分:5)
public int getBiggestInTheColumn()
{
Cursor c = db.query(HEADER_TABLE, null,new String[] {"MAX(key_Division)"}, null, null, null, null);
try {
c.moveToFirst();
return c.getInt(0);
} finally {
c.close();
}
}