谁能告诉我如何在SQLITE中获得最高数字并将其设置为TextView?
public Cursor MaxPrice() {
Cursor m = ourDatabase.rawQuery("SELECT MAX( " + Pro_Price + " ) FROM "+ TABLE_NAME + " " , null);
return m;
}下面是其他类中的另一部分:
Database dbb = new Database(this);
dbb.open();
String Hexpense = dbb.MaxPrice();
tvHighestExpense.setText( Hexpense);发布于 2013-06-09 03:30:43
您的方法MaxPrice()返回一个游标。因此,您应该从游标包含的第一行(也是唯一行)提取值:
Cursor c = dbb.MaxPrice()
c.moveToFirst();
if (!c.isAfterLast()) {
tvHighestExpense.setText(c.getLong(0));
}发布于 2013-06-09 02:59:54
Cursor m=...
long max=m.getLong(0/*column index*/);
tvHighestExpense.setText(String.valueOf(max));https://stackoverflow.com/questions/17002771
复制相似问题